DATE_PART

The DATE_PART() function extracts a subfield from a date value.

Syntax

DATE_PART(field,source)

Field - is a constant value that specifies the sub-field (for example, year, day, etc) to extract from the given date or timestamp.

Source - is the input date that will be processed.

Example

SELECT date_part(year,orderdate)
from
/shared/examples/ds_orders/tutorial/orders

The above query returns the year part from the orderdate column.