View Full Version : comparing the today's date with timestamp value

06-05-2007, 09:28 AM

i have a mysql table which has 3 fields
1.id 2.username 3.time
1 abcd 1181027044

i want to fetch only those user id's and usernames whos time is equal to current date.any of your idea will be surely appreciated.


06-05-2007, 02:51 PM
SELECT `id`, `username` FROM `tablename` WHERE `time`=TIMESTAMP(NOW());

I'm not sure if you need NOW() in there or not. But this will only select for values down to the second. Perhaps you want this to display users who just signed up today, in which case;

SELECT `id`, `username` FROM `tablename` WHERE DATE(FROM_UNIXTIME(`time`)) = DATE(NOW());

Again, not sure about the need for the NOW(). Actually I'm not 100% sure about the SQL in general, perhaps someone with more SQL experience would like to correct or optimize my suggestion.