[thelist] sql query for sum of timediff

Matt Warden mwarden at gmail.com
Fri Jun 2 10:56:25 CDT 2006


On 6/2/06, Canfield, Joel <JCanfield at pacadvantage.org> wrote:
> > If you do this, do you get any rows?:
> >
> > select *
> > from presence
> > where starttime is null OR endtime is null
>
> yup; some endtimes are null, which would whack the calculation, huh?

No. They are not included in your result because of your where clause.

> so, adding 'and endtime is not null' still gives me unusual results,

Adding this clause is redundant.

> five zeroes and a one, when I know the totals should be between 5 and 8
> hours; perhaps it's the format? but if I try
>
>     date_format(sum(timediff(endtime,starttime)),'%H:%i:%s')
>
> they're all null.

Did you try my suggestion?
http://lists.evolt.org/archive/Week-of-Mon-20060529/182645.html


-- 
Matt Warden
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list