List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:October 24 2005 2:11pm
Subject:Re: sum of time?
View as plain text  
> >>This translated to SQL as:
> >>
> >>select SEC_to_time(SUM(unix_timestamp(TTendTime)) -
> >>SUM(unix_timestamp(TTstartTime)))
> >>as endtime
> >>FROM TimeTracking
> >>WHERE TTperson = 1
> >>    and date(TTstartTime) = '2005-10-19'
> >
> > Won't this fail if it overflows 24 hours?
> >
> > Given that the result of SEC_TO_TIME seems to be a valid "time value",
> > which "duration" is not?
> >
> > eg: a duration can be 25 hours long, while a TIME value cannot.
>
> First, it is hard to imagine how that would happen given the OP's
situation.
>
> Second, no, it won't overflow:
>
>    mysql> SELECT SEC_TO_TIME(60*60*24*5);
>    +-------------------------+
>    | SEC_TO_TIME(60*60*24*5) |
>    +-------------------------+
>    | 120:00:00               |
>    +-------------------------+
>    1 row in set (0.00 sec)
>
>    mysql> SELECT SEC_TO_TIME(60*60*24*50);
>    +--------------------------+
>    | SEC_TO_TIME(60*60*24*50) |
>    +--------------------------+
>    | 1200:00:00               |
>    +--------------------------+
>    1 row in set (0.00 sec)
>
> SEC_TO_TIME() is not limited to 24 hours.

Aha, right - thanks for that.

It seems to be a display error on my side :-)

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

Thread
sum of time?jabbott24 Oct
  • Re: sum of time?Dobromir Velev24 Oct
    • mysql + LVSWinn Johnston24 Jul
      • RE: mysql + LVSJimmy Guerrero24 Jul
        • RE: mysql + LVSWinn Johnston25 Jul
          • RE: mysql + LVS highjacked (mysql + NFS ramfs)Winn Johnston25 Jul
            • RE: mysql + LVS highjacked (mysql + NFS ramfs)Barry Newton25 Jul
  • Re: sum of time?SGreen24 Oct
    • Re: sum of time?Martijn Tonies24 Oct
      • Re: sum of time?Michael Stassen24 Oct
        • Re: sum of time?Michael Stassen24 Oct
    • Re: sum of time?Martijn Tonies24 Oct
    • Re: sum of time?Martijn Tonies24 Oct
      • Re: sum of time?SGreen24 Oct
        • Re: sum of time?jabbott24 Oct