DAYOFMONTH
The DAYOFMONTH function returns the day part of a value. The function is similar to the DAY function, except DAYOFMONTH does not support a date or timestamp duration as an argument.
The schema is SYSIBM.
The argument must be an expression that returns a value of a date, a timestamp, a character string, or a graphic string built-in data type.
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 with an actual length that is not greater than 255 bytes. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
If expression is a timestamp with a time zone value, or a valid string representation of a timestamp with a time zone, the result is determined from the UTC representation of the datetime value.
The result of the function is a large integer between 1 and 31, which represents the day part of the value.
The result can be null; if the argument is null, the result is the null value.
SELECT DAYOFMONTH(HIREDATE)
INTO :DAYVAR
FROM DSN8A10.EMP
WHERE EMPNO = '000140';
SELECT DAYOFMONTH('2003-01-02-20.00.00'),
DAYOFMONTH('2003-01-02-12.00.00-08:00'),
DAYOFMONTH('2003-01-03-05.00.00+09:00')
FROM SYSIBM.SYSDUMMY1;
For each invocation of the DAYOFMONTH
function in this SELECT statement, the result is 2.When the input argument contains a time zone, the result is determined from the UTC representation of the input value. The string representations of a timestamp with a time zone in the SELECT statement all have the same UTC representation: 2003-01-02-20.00.00. The day portion of the UTC representation is 2.