Page 1 of 1

Selecting distinct yearr from unix_timestamp

Posted: Sat Feb 03, 2007 9:06 am
by Shenz
Hello,

I have a large number of unix_timestamps in mij database. Now I would like to retrieve all the distinct years from these timestamps to use them further on with PHP. Is it possible to do this an MySQL query? If not, is there a good way to this with PHP? Or should I change from unix_timestamp to datetime?

Thanx in advance for helping this newbie ;)!

Posted: Sat Feb 03, 2007 9:09 am
by feyd
The MySQL FROM_UNIXTIME() function may be of interest.

Posted: Sat Feb 03, 2007 1:01 pm
by Shenz
Thx, that helped :)

This is the query I'm using now: SELECT DISTINCT DATE_FORMAT(FROM_UNIXTIME(column), '%Y') AS year