...

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



mrjameer
06-05-2007, 08:28 AM
hi,



i have a mysql table which has 3 fields
1.id 2.username 3.time
values
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.


thanks
mrjameer

Ahri
06-05-2007, 01: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum