date_trunc
trunc
date_trunc('field', source)
sourcetimestampintervaldatetimetimestampintervalfieldtimestampinterval
field
microseconds |
milliseconds |
second |
minute |
hour |
day |
week |
month |
quarter |
year |
decade |
century |
millennium |
Examples:
SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40'); Result: 2001-02-16 20:00:00 SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40'); Result: 2001-01-01 00:00:00
来源:博客园
作者:李小智
链接:https://www.cnblogs.com/lixiaozhi/p/11670831.html