[AccessD] Tip: Sum elapsed time and display as a time string

Gustav Brock Gustav at cactus.dk
Wed Feb 4 01:27:21 CST 2009


Hi all

Did you know how easy it is in a query to sum elapsed time (of date/time value) and format this as a string even when count of hours exceed 24?

SELECT 
    DateDiff("h",0,Sum([ElapsedTime])) & 
    Format(Sum([ElapsedTime]),":nn:ss") AS 
  ElapsedTimeTotal
FROM 
  tblElapsedTime;

This will return a string like, say, 45:37:12.

The trick is, of course, to count the hours from date/time value 0 (zero). Then let Format handle the minutes and seconds.

/gustav





More information about the AccessD mailing list