SQL - Scalar functions - FIRST_DAY


Volta a página anterior

Volta ao Menu das scalar functions

Volta ao Menu Principal


Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

FIRST_DAY

The FIRST_DAY function returns a date or timestamp that represents the first day of the month of the argument.

FIRST_DAY(expression )

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

  1. Set the host variable FIRST_OF_MONTH with the first day of the current month.
       SET :FIRST_OF_MONTH = FIRST_DAY(CURRENT_DATE)
    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.
  2. Set the host variable FIRST_OF_MONTH with the first day of the month in IBM® European standard format for the given date.
       SET :FIRST_OF_MONTH = CHAR(FIRST_DAY(DATE '1965-07-07'), EUR)
    The host variable FIRST_OF_MONTH is set with the value '01.07.1965'.

© Copyright IBM Corp.