Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    comparing the today's date with timestamp value

    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

  • #2
    New Coder
    Join Date
    May 2007
    Location
    Manchester, UK
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.
    Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •