FIRST_DAY scalar function
The FIRST_DAY function returns a date or timestamp that represents the first day of the month of the argument.
The schema is SYSIBM.
- expression
- An expression that specifies the datetime value to compute the first day of the month. The expression must return a value that is a DATE, TIMESTAMP, CHAR, or VARCHAR data type. In a Unicode database, the expression can also be a GRAPHIC or VARGRAPHIC data type. CHAR, VARCHAR, GRAPHIC, and VARGRAPHIC are supported by using implicit casting. If expression is a CHAR, VARCHAR, GRAPHIC, or VARGRAPHIC data type, it must be a valid string that is accepted by the TIMESTAMP scalar function.
The result of the function is a timestamp with the same precision as expression, if expression is a timestamp. Otherwise, the result of the function is a date. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
Examples
- Set the host variable FIRST_OF_MONTH with the first day of the
current month.
The host variable FIRST_OF_MONTH is set with the value representing the beginning of the current month. If the current day is 2000-02-10, then FIRST_OF_MONTH is set to 2000-02-01.SET :FIRST_OF_MONTH = FIRST_DAY(CURRENT_DATE)
- Set the host variable FIRST_OF_MONTH with the first day of the
month in IBM® European standard
format for the given date.
The host variable FIRST_OF_MONTH is set with the value '01.07.1965'.SET :FIRST_OF_MONTH = CHAR(FIRST_DAY(DATE '1965-07-07'), EUR)