Skip to content

DATE_PART

Return a specific date part, such as the month or day, for a date, a timestamp (with or without time zone), or an interval literal.

DATE_PART('datepart', { date | timestamp | timestamptz | interval }

See Supported Date Parts. The DATE_PART function does not support all date parts in all cases. For example, if the second argument is an interval literal, which represents a duration of time, the date part cannot be week, which signifies a specific ISO week number in the calendar year.

For example:

premdb=# SELECT matchday, DATE_PART('week',matchday) FROM match LIMIT 2;
     matchday       | date_part 
---------------------+-----------
 2006-10-28 00:00:00 |        43
 2006-09-16 00:00:00 |        37
(2 rows)
premdb=# SELECT DATE_PART('day',INTERVAL '2 weeks');
 date_part 
-----------
       14
(1 row)