SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem comparing INTs in a mysql query

    Hey all,

    I am trying to retreive from my DB events that have a starting time on the current day or later, hence hiding events that have already taken place.
    I have timestamps stored as INTs in my DB.
    Here is what I am doing, but it returns 0 rows.
    I have looked at the numbers, and it "should" work properly... but I am probably overlooking something dumb

    PHP Code:
    $beforetime mktime (0,0,0,date("m"),date("d"),date("Y"));
    $get_events mysql_query("select * from events where starttime > ".$beforetime." order by startdate asc limit 5"); 
    If I hard code a 5 or something in the query it works... if I hard code the actual 10 digit timestamp, it doesnt work...

    What I am missing?

    Thanks
    James Rice :: Ex-Mentor
    www.jamesrice.net

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    why are you storing times as INTs? why not DATETIME?

  3. #3
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, I actually realized I was using the wrong field in the comparison....
    so it works fine now.

    I use ints out of habit...
    James Rice :: Ex-Mentor
    www.jamesrice.net

  4. #4
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use 10-digit INTs if you are using UNIX-Style timestamps to store the time. This would be a perfectly valid reason for using INT columns for time.

  5. #5
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes thats what I am doing.
    James Rice :: Ex-Mentor
    www.jamesrice.net

  6. #6
    Non-Member
    Join Date
    Jul 2005
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use 11 int for time/date.


Bookmarks

Posting Permissions

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