Page 1 of 1

[solved] selecting certain months

Posted: Mon Nov 24, 2003 12:42 am
by Nay
Okay, I asked this question ealier before and got it but now I'm using a different approach for the date. I have a MySQL timestamp, and I want to select the months from it.

Before:

Code: Select all

news | date | month | comments

yay!  | 9-11 | jan     |  none
yay!  | 9-11 | jul     |  none
yay!  | 9-11 | dec     |  none
then I could do a:

Code: Select all

select distinct month from news
but now i have the timestamp for the date:

Code: Select all

news | date                | comments

yay!  | 121020031155 |  none
yay!  | 111220031155 |  none
yay!  | 101120031155 |  none
i tried to:

Code: Select all

SELECT DATE_FORMAT( date, '%m-%y' ) AS formatted_date DISTINCT formatted_date
FROM news
but that threw up an error when i tried it in phpmyadmin. any ideas?

thanks,

-Nay

Posted: Mon Nov 24, 2003 12:56 am
by infolock
i dn't have any dates like that, but it's called idate.

maybe this will help :

http://www.mysql.com/doc/en/Using_DATE.html

i'd also look up on google for idate conversions

Posted: Mon Nov 24, 2003 1:29 am
by Nay
Hey, thanks for the helpy link. I always forget to check with mysql.com O_o. Anyhow, I've got it solved:

Code: Select all

SELECT DISTINCT DATE_FORMAT(date, '%M %Y') AS formatted_date ORDER BY formatted_date ASC
-Nay