Home > ASP Development > Calculate timings

Calculate timings



I have timings in tottime column in access database



00:45:58

00:40:05

00:25:24

00:00:58



etc

how to calculate these timings.



Can you let me know.

    
Guest


Quote:
Can you let me know.
Not from the vague posting you made. Try providing the specifics of what you want to accomplish.

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by Doug G
Not from the vague posting you made. Try providing the specifics of what you want to accomplish.




I want to get the total timings of those in asp

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by sbhavan_s
I want to get the total timings of those in asp




as doug mentioned it's too vague..even though you want total...do you want this at the query or in your asp code...do you need in the same format as what you have? if so...how are you going to handle the situation IF the hours total 24? i based on the assumption you want to base on days so you may need to adjust as needed...i imagine you could do all this with nested queries, but, w/ limited info i opted to demonstrate converting the times in the database to seconds...then use a function to convert to day time




Code:



' this function converts a number representing seconds
' and breaks it down into days, hours, minutes, seconds


Function ConvertSecondsToElapsedTime(iTotSeconds)
iDays = int(iTotSeconds / 86400)
iHours = int((iTotSeconds / 3600) - (iDays * 24))
iMinutes = int((iTotSeconds / 60) - (iDays * 1440) - (iHours * 60))
iSeconds = int((iTotSeconds mod 60))

ConvertSecondsToElapsedTime = iDays & " " & (iHours & ":" & iMinutes & ":" & iSeconds)
End Function

' this query converts tottime field to total seconds
Set oRs = oConn.Execute("SELECT Sum((Hour(tottime)*3600)+(Minute(tottime)*60)+Seco nd(tottime)) AS tot_secs " & _
"FROM your_table;")

If not oRs.eof then
iTotSeconds = oRs("tot_secs")
Response.write ConvertSecondsToElapsedTime(iTotSeconds)
End if
%>



Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2010 by Infoqu. All rights reserved