I have a Log table and this is it's description:
user_id(bigint)
time (bigint)
My question is, how can I extract the year from the time column in PostgreSQL?
This works in MySQL:
SELECT l.user_id, year(from_unixtime(l.time))
FROM log l;
select date_part('year', to_timestamp(1365682413));
to_timestamp is our friend here and has taken a unix time since at least version 8.1.
select extract(year from timestamp 'epoch' + "time" * interval '1 second')
from log;