Appearance
DATE_TRUNC
Truncate a datetime expression to the first hour, day, or month (for example), for that expression.
DATE_TRUNC('datepart', expression)
See Supported Dateparts.
For example, return matchday
values truncated to the first of their respective months:
premdb=# SELECT matchday, DATE_TRUNC('month', matchday)
FROM match WHERE htid = 10 ORDER BY 1 LIMIT 3;
matchday | date_trunc
---------------------+---------------------
1999-08-14 00:00:00 | 1999-08-01 00:00:00
1999-08-28 00:00:00 | 1999-08-01 00:00:00
1999-09-12 00:00:00 | 1999-09-01 00:00:00
(3 rows)
Parent topic:Datetime Functions