Extraction Functions
This section contains extraction functions that extract unit
from an input expression. The table below contains the supported units for the given extraction functions.
Unit | Description |
---|---|
YEAR | extracts year |
QUARTER | extracts quarter |
MONTH | extracts month |
WEEK | extracts week of the year |
DAY | extracts day |
DOY | extract the day of the year |
DOW | extract ISO day of the week (ranges from 1 (Monday) to 7 (Sunday) |
HOUR | extracts hour |
MINUTE | extracts minute |
SECOND | extracts second |
EPOCH | extracts epoch time |
EXTRACT( unit FROM <datetime expr> )
Returns the value of specified unit
from the given date-time expression.
DATEPART( unit, <expr> )
Returns the specified unit of the given date/timestamp expression.
WEEK( <date_or_timestamp_expr> )
Returns the week number of the year.
YEAR( <date_or_timestamp_expr> )
Returns the year for a date or timestamp.
MONTH( <date_or_timestamp_expr> )
Returns the month for a date or timestamp.
DAYS( <date_or_timestamp_expr> )
Returns the day of the month for a date or timestamp.
LAST_DAY( <date_or_timestamp_expr> )
Return the last day of the month for a date or timestamp.
DAYNAME( <date_or_timestamp_expr> )
Returns the three-letter day-of-week name for a date or timestamp.
HOUR( <date_or_timestamp_expr> )
Returns the hour of the day from timestamp. The value ranges from 0
to 23
.
MINUTE( <date_or_timestamp_expr> )
Returns the minute of the hour from timestamp. The value ranges from 0
to 59
.
SECOND( <date_or_timestamp_expr> )
Returns the second of the minute from timestamp. The value ranges from 0
to 59
.
DAYOFWEEKISO( <date_or_timestamp_expr> )
Day (number) of the week uses ISO semantics 1 to 7
WEEKOFYEAR( <date_or_timestamp_expr> )
Week (number) of the year 1 to 53.
WEEKISO( <date_or_timestamp_expr> )
WEEKISO is the same as WEEKOFYEAR, except uses ISO semantics 1 to 53.
Last updated