EXTRACT
Description
EXTRACT
is a row function that returns the specified portion of a DATE
value.Syntax
EXTRACT
("extract_value
",DATE
)Return Value
Returns the specified extracted value as type
INTEGER
. EXTRACT
removes leading zeros. For example, the month of April returns a value of 4
, not 04
.Input Parameters
- extract_value
- Required. One of the following extract values:
- - Returns the millisecond portion of a date value. For example, an input date value ofmillisecond2012-08-15 20:38:40.213would return an integer value of213.
- - Returns the second portion of a date value. For example, an input date value ofsecond2012-08-15 20:38:40.213would return an integer value of40.
- - Returns the minute portion of a date value. For example, an input date value ofminute2012-08-15 20:38:40.213would return an integer value of38.
- - Returns the hour portion of a date value. For example, an input date value ofhour2012-08-15 20:38:40.213would return an integer value of20.
- - Returns the day portion of a date value. For example, an input date value ofday2012-08-15would return an integer value of.15
- - Returns the ISO week number for the input date value. For example, an input date value ofweek2012-01-02would return an integer value of1(the first ISO week of 2012 starts on Monday January 2). An input date value of2012-01-01would return an integer value of52(January 1, 2012 is part of the last ISO week of 2011).
- - Returns the month portion of a date value. For example, an input date value ofmonth2012-08-15would return an integer value of8.
- - Returns the quarter number for the input date value, where quarters start on January 1, April 1, July 1, or October 1. For example, an input date value ofquarter2012-08-15would return a integer value of3.
- - Returns the year portion of a date value. For example, an input date value ofyear2012-01-01would return an integer value of2012.
- - Returns the year value that corresponds to the ISO week number of the input date value. For example, an input date value ofweekyear2012-01-02would return an integer value of2012(the first ISO week of 2012 starts on Monday January 2). An input date value of2012-01-01would return an integer value of2011(January 1, 2012 is part of the last ISO week of 2011).
- date
- Required. A field name or expression that returns aDATEvalue.
Examples
Extract the hour portion from the
order_date
Date field:EXTRACT("hour",[order_date])
Cast the value of the
order_date
Text
field to a date value using TO_DATE
, and extract the ISO week year:EXTRACT("weekyear",TO_DATE([order_date],"MM/dd/yyyy HH:mm:ss"))