SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-59
EXTRACT Function
EXTRACT Function
The EXTRACT function extracts a datetime field from a datetime or interval value
expression. It returns an exact numeric value.
See Datetime Value Expressions on page 6-39 and Interval Value Expressions on
page 6-43.
Examples of EXTRACT
Extract the year from a DATE value:
EXTRACT (YEAR FROM DATE '1996-09-28')
The result is 1996.
Extract the year from an INTERVAL value:
EXTRACT (YEAR FROM INTERVAL '01-09' YEAR TO MONTH)
The result is 1.
EXTRACT (datetime-field FROM extract-source)
datetime-field is:
YEAR | MONTH | DAY | HOUR | MINUTE | SECOND
extract-source is:
datetime-expression | interval-expression