Truncate datetime

SELECT DISTINCT
       date_trunc('minute', "when") AS minute
     , count(*) OVER (ORDER BY date_trunc('minute', "when")) AS running_ct
FROM   mytable
ORDER  BY 1;

Extract parts of datetime

Ref date_part

SELECT date_part('year', "inserted_at") FROM users