postgres date_trunc code example
Example 1: date_trunc postgres
SELECT DATE_TRUNC('hour', TIMESTAMP '2017-03-17 02:09:30');
Example 2: postgresql today - 1 year
select now() - INTERVAL '1 YEAR';
SELECT DATE_TRUNC('hour', TIMESTAMP '2017-03-17 02:09:30');
select now() - INTERVAL '1 YEAR';