The NEXT_DAY function returns a timestamp that represents the first weekday, named by string-expression, that is later than the date expression. If expression is a timestamp or valid string representation of a timestamp, the timestamp value has the same hours, minutes, seconds, and microseconds as expression. If expression is a date, or a valid string representation of a date, then the hours, minutes, seconds, and microseconds value of the result is 0.
If expression is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be a valid string representation of a date or timestamp. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
Day of Week | Abbreviation |
---|---|
MONDAY | MON |
TUESDAY | TUE |
WEDNESDAY | WED |
THURSDAY | THU |
FRIDAY | FRI |
SATURDAY | SAT |
SUNDAY | SUN |
The result of the function is a timestamp. If either argument can be null, the result can be null; if either argument is null, the result is the null value.
National language considerations: The values of the days of the week (or abbreviations) in string-expression may either be the US English values listed in the table above or the values based on the language used for messages in the job. The non-abbreviated name of the day is retrieved from message CPX9034 in message file QCPFMSG in library *LIBL. The abbreviated name of the day is retrieved from message CPX9039 in message file QCPFMSG in library *LIBL.
Applications that need to run in many different language environments may want to consider using US English values since they will always be accepted in the NEXT_DAY function.
SET :NEXTDAY = NEXT_DAY(CURRENT_DATE, 'TUESDAY')
The host variable NEXTDAY is set with the value of '2000-04-25-00.00.00.000000', assuming that the value of the CURRENT_DATE special register is '2000-04-24'.
SET :NEXTDAY = NEXT_DAY(LAST_DAY(CURRENT_TIMESTAMP), :DAYHV)
The host variable NEXTDAY is set with the value of '2000-05-01-12.01.01.123456', assuming that the value of the CURRENT_TIMESTAMP special register is '2000-04-24-12.01.01.123456'.
SELECT NEXT_DAY('2000-04-24', 'TUESDAY') FROM SYSIBM.SYSDUMMY1
Returns '2000-04-25-00.00.00.000000', which is the Tuesday following '2000-04-24'.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.