[thelist] Free Tip - Calculating Hours, Minutes, and Seconds in SQL

Rob Smith rob.smith at lexjet.com
Tue Mar 14 13:30:04 CST 2006

<tip type="" author="Me">
If you have summed fields for total time in seconds you can use this
quick bit of code to separate that field into three fields with hours,
minutes, and seconds. This is for SQL Server 200X:
SELECT floor(sum([DuractionSec])/60/60) as Hours,
(floor(sum([DuractionSec])/60)-floor(sum([DuractionSec])/60/60)*60) as
Minutes , (sum([DuractionSec])-floor(sum([DuractionSec])/60)*60) as

It game my brain a run for the money...

Rob Smith
rob.smith at lexjet.com
(941)330-1210 Int'l
(941)330-1220 Fax
1680 Fruitville Road, 3rd Floor
Sarasota, FL 34236

Proud Sponsors of the Professional Digital Imaging Association (www.pdia.org)

More information about the thelist mailing list