Extract Date Values
>>-EXTRACT--(--+-YEAR--+--FROM--+-date-expression------+--)---->< +-MONTH-+ '-timestamp-expression-' '-DAY---'
Extract Time Values
>>-EXTRACT--(--+-HOUR---+--FROM--+-time-expression------+--)--->< +-MINUTE-+ '-timestamp-expression-' '-SECOND-'
The EXTRACT function returns a specified portion of a datetime value.
Extract Date Values
If expression is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be a valid character-string or graphic-string representation of a date. For the valid formats of string representations of dates, see String representations of datetime values.
If expression is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be a valid character-string or graphic-string representation of a timestamp. For the valid formats of string representations of timestamps, see String representations of datetime values.
Extract Time Values
DECIMAL((DAY(expression) + DECIMAL(MICROSECOND(expression),12,6)/1000000), 8,6)For more information, see SECOND and MICROSECOND.
If expression is a character string, it must not be a CLOB and its value must be a valid character-string representation of a time. For the valid formats of string representations of times, see String representations of datetime values.
If expression is a character string, it must not be a CLOB and its value must be a valid character-string representation of a timestamp. For the valid formats of string representations of timestamps, see String representations of datetime values.
The data type of the result of the function depends on the part of the datetime value that is specified:
If the argument can be null, the result can be null; if the argument is null, the result is the null value.
SELECT EXTRACT( MONTH FROM PRSTDATE ) FROM PROJECTResults in the value 12.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.