SQL - Scalar functions - NEXT_DAY
The NEXT_DAY scalar function returns a datetime value that represents the first weekday, named by string-expression, that is later than the date in expression.
The schema is SYSIBM.
The minimum length of the input value is the length of the abbreviation. The characters can be specified in lower or upper case and any characters immediately following a valid abbreviation are ignored.
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 TIMESTAMP(6). The result can be null; if any argument is null, the result is the null value.
Any hours, minutes, seconds or fractional seconds information included in expression is not changed by the function. If expression is a string representing a date, the time information in the resulting TIMESTAMP value is all set to zero.
SET NEXTDAY = NEXT_DAY(DATE '2007-04-24', 'TUESDAY')
The variable NEXTDAY is set with the value of '2007-05-01', since April 24, 2007 is itself a Tuesday.
SET NEXTDAY = NEXT_DAY(LAST_DAY(CURRENT_TIMESTAMP), DAYOFWEEK)
The variable vNEXTDAY is set with the value of '2007-05-07-12.01.01.123456', assuming that the value of the CURRENT_TIMESTAMP special register is '2007-04-24-12.01.01.123456'.