Selecting distinct yearr from unix_timestamp

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Shenz
Forum Newbie
Posts: 16
Joined: Sat Nov 25, 2006 10:47 am

Selecting distinct yearr from unix_timestamp

Post 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 ;)!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The MySQL FROM_UNIXTIME() function may be of interest.
Shenz
Forum Newbie
Posts: 16
Joined: Sat Nov 25, 2006 10:47 am

Post by Shenz »

Thx, that helped :)

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