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.
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.
SELECT LAST_DAY(DATE '1999-12-19');
The result would be the following one.
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.
SELECT LAST_DAY(TIMESTAMP '1999-12-19 23:58:12.17');
The result would be the following one.
1999/12/31
See also