Answered by:
Sum time in time format
Question

Answers

The following function will take a number of seconds and calculate the number of days, hours, minutes & seconds... In the following format: dd:hh:mm:ss
Function DHMS(NumberOfSeconds as Long) as String Dim NumberOfMinutes as Long Dim NumberOfHours as Long Dim NumberOfDays as Long
NumberOfDays = NumberOfSeconds \ 86400 NumberOfSeconds = NumberOfSeconds Mod 86400 NumberOfHours = NumberOfSeconds \ 3600 NumberOfSeconds = NumberOfSeconds Mod 3600 NumberOfMinutes = NumberOfSeconds \ 60 NumberOfSeconds = NumberOfSeconds Mod 60 DHMS = IIf(NumberOfDays < 10, "0" & NumberOfDays, NumberOfDays) & " : " & _ IIf(NumberOfHours < 10, "0" & NumberOfHours, NumberOfHours) & " : " & _ IIf(NumberOfMinutes < 10, "0" & NumberOfMinutes, NumberOfMinutes) & " : " & _ IIf(NumberOfSeconds < 10, "0" & NumberOfSeconds, NumberOfSeconds) End FunctionThen you reference the the code in a formula like this...
=Code.DHMS(Fields!DiffSecs.Value)
Jason Long Marked as answer by sappunni Tuesday, January 25, 2011 6:27 PM
All replies


I have a column which is the time the user has spent on differnt tasks like loging in, contact customer, etc the format of the time is in time(7) format hh:mm:ss:xxxxxxx when I try to do =sum(Fields!Timespent.Value) I get a 00:00:00:000000
The values in the column timespent are like 02:22:00:000000 00:59:00:000000 etc
Thank you!!!

The following function will take a number of seconds and calculate the number of days, hours, minutes & seconds... In the following format: dd:hh:mm:ss
Function DHMS(NumberOfSeconds as Long) as String Dim NumberOfMinutes as Long Dim NumberOfHours as Long Dim NumberOfDays as Long
NumberOfDays = NumberOfSeconds \ 86400 NumberOfSeconds = NumberOfSeconds Mod 86400 NumberOfHours = NumberOfSeconds \ 3600 NumberOfSeconds = NumberOfSeconds Mod 3600 NumberOfMinutes = NumberOfSeconds \ 60 NumberOfSeconds = NumberOfSeconds Mod 60 DHMS = IIf(NumberOfDays < 10, "0" & NumberOfDays, NumberOfDays) & " : " & _ IIf(NumberOfHours < 10, "0" & NumberOfHours, NumberOfHours) & " : " & _ IIf(NumberOfMinutes < 10, "0" & NumberOfMinutes, NumberOfMinutes) & " : " & _ IIf(NumberOfSeconds < 10, "0" & NumberOfSeconds, NumberOfSeconds) End FunctionThen you reference the the code in a formula like this...
=Code.DHMS(Fields!DiffSecs.Value)
Jason Long Marked as answer by sappunni Tuesday, January 25, 2011 6:27 PM

