Jump to content

Archived

This topic is now archived and is closed to further replies.

t_machine

How to compare dates in mysql query

Recommended Posts


hi, I am wondering if anyone can help me with this date problem. I have a database that stores username and date(unix timestamp). I would however like to list all the usernames within the current month. Something like this would be great.

$thismonth = date('m,Y', time()); // 04,2006
"SELECT username FROM TABLENAME WHERE date_added ='$thismonth'

how can i strip the 'date_added' which is in timestamp to month and year so I could compare and list the users within that month. Thanks :)

Share this post


Link to post
Share on other sites

[code].... WHERE DATE_FORMAT(FROM_UNIXTIME(date_added), '%m,%Y') = '$thismonth'[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.