Web4College

LAST_DAY in Teradata

LAST_DAY function accepts DATE or TIMESTAMP string and returns the date of the last day of the month. See the syntax of LAST_DAY in Teradata given below. If you want to get only the last day of the month. You may use EXTRACT function to extract day from the date.

Example

LAST_DAY(DATE date_expression);
LAST_DAY(TIMESTAMP datetime_expression);

date_expression represents the date string only.

datetime_expression represents both the date and time string.


See the following examples to understand.

Example 1:

In the following example, LAST_DAY function accepts date string and returns the date of the last day of the month in Teradata.

Example

SELECT LAST_DAY(DATE '1999-12-19');

The result would be the following one.

Example

1999/12/31

Example 2:

In the following example, LAST_DAY function accepts dateTime string and returns the date of the last day of the month in Teradata.

Example

SELECT LAST_DAY(TIMESTAMP '1999-12-19 23:58:12.17');

The result would be the following one.

Example

1999/12/31

See also

subtract dates in teradata

EXTRACT function in teradata