LAST_DAY scalar function
The LAST_DAY scalar function returns a date that represents the last day of the month of the date argument.
The schema is SYSIBM.
- expression
- An expression that specifies the starting date. The expression
must returns a value of one of the following data types:
- a date
- a timestamp
- a valid string representation of a date or timestamp
An argument with a character string data type must not be a CLOB. An argument with a graphic string data type must not be a DBCLOB. A string argument must have an actual length that is not greater than 255 bytes. A time zone in a string representation of a timestamp is ignored. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
If expression is a TIMESTAMP WITH TIME ZONE value, expression is first cast to a TIMESTAMP WITHOUT TIME ZONE value with the same precision as expression.
The result of the function has the same data type as expression, unless expression is a string, in which case the result data type is DATE.
The result CCSID is the appropriate CCSID of the argument encoding scheme and the result subtype is the appropriate subtype of the CCSID.
The result can be null; if the argument is null, the result is the null value.
Any hours, minutes, seconds, or fractional seconds information that is included in expression is not changed by the function.
SET :END_OF_MONTH = LAST_DAY(CURRENT_DATE);
The
host variable END_OF_MONTH is set with the value
representing the end of the current month. If the current day is 2000-02-10, END_OF_MONTH is
set to 2000-02-29. SET :END_OF_MONTH = CHAR(LAST_DAY('1965-07-07'), EUR);
The
host variable END_OF_MONTH is set with the value
'31.07.1965'. SELECT LAST_DAY(:PRSTSZ)
FROM PROJECT;
The LAST_DAY function returns the value
'31' (month in UTC is March).SELECT LAST_DAY(:PRSTSZ)
FROM PROJECT;
The LAST_DAY function returns the value
‘2008-04-30', the last day of the month of April, as a DATE
value.SELECT LAST_DAY('2000-04-24')
FROM SYSIBM.SYSDUMMY1;