15.00 - LAST_DAY - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

LAST_DAY

Purpose  

Returns the date of the last day of month that contains date_timestamp_value.

Syntax  

where:

 

Syntax element …

Specifies …

TD_SYSFNLIB

the name of the database where the function is located.

date_timestamp_value

a data or timestamp argument.

If date_timestamp_value is NULL, NULL is returned

ANSI Compliance

This is a Teradata extension to the ANSI SQL:2011 standard.

Invocation

LAST_DAY is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.

Argument Types and Rules

Expressions passed to this function must have one of the following data types:

DATE, TIMESTAMP, or TIMESTAMP WITH TIME ZONE

Since TIMESTAMP values are stored in UTC time within the database and lack a time zone, the session time zone is used to interpret the time stamp value within the function. For TIMESTAMP WITH TIME ZONE values, the time zone component is used to interpret the time stamp value within the function.

Result Type

The return data type is DATE.

Example  

The following query:

SELECT LAST_DAY(DATE '2009-12-20'); 

returns the result 09/12/31.

Example  

The following query:

SELECT LAST_DAY(TIMESTAMP '2009-08-25 10:14:59'); 

returns the result 09/08/31.

Example  

The following query:

SELECT LAST_DAY(TIMESTAMP '2009-06-15 10:14:59-8:00');

returns the result 09/06/30.