MySQL Time Difference BUG

Discussion in 'MySQL' started by cancer10, Feb 14, 2009.

  1. cancer10

    cancer10 New Member

    Joined:
    Jul 12, 2008
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Webmaster
    Location:
    India
    Hi

    Not sure if this is a bug or not.


    I am doing a sql query for time difference using the TIMEDIFF function.

    It works for all other but not when not when you are doing a time difference for start time 23:00:00 (11 PM night) and end time 00:30:00 (12 AM Midnight)

    if you take a look, the difference is 1.5 hours, but the sql tells me that the difference is 22 hours, 30 minutes



    Any solution to this?

    Thanx
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    That means it takes the date into account and assumes the same day.
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    48
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Logically what MySQL returns is correct, 00 hr onwards is next day, so you must include the date part!

    Code:
    select timediff('2009-05-28 11:30:00','2009-05-28 00:30:00')
    
    Outputs:
    Code:
    11:00:00
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice