29
Crystal Reports: ElapsedTime() Function
1 Comment · Posted by Craig Buchanan in Crystal Reports, Functions, Programming
Converts a number of seconds into a string in the format of days.hours:minutes:seconds.
Function (NumberVar interval)
NumberVar Days := Truncate(interval / 86400);
NumberVar Hours := Truncate(Remainder(interval, 86400) / 3600);
NumberVar Minutes := Truncate(Remainder(interval, 3600) / 60);
NumberVar Seconds := Remainder(interval, 60);
Totext(Days,'##') +'.'+ Totext(Hours,'00') +':'+ Totext(Minutes,'00') +':'+ Totext(Seconds,'00')
Parameters
- interval
- The number of seconds to be converted.
Return Value
A string in the format of days.hours:minutes:seconds
Remarks
none
Example
//returns 0.00:02:12
ElapsedTime(132)
//formats the difference between two datetime values.
ElapsedTime ((CurrentDateTime-DateTime(2006,1,1,0,0,0))*86400)
//formats the difference between two datetime values.
ElapsedTime (DateDiff("s", {TABLE.FIELD}, CurrentDateTime))
Requirements
This function requires the use of Crystal Syntax.

DR · September 21, 2006 at 9:37 am
I couldnt get the function to work;
but it gave me the direction to get the formula to work as part of a formula field in the footer.
Ya have to wonder why this isnt a default part of all programming programs. Many Thanx! I really needed this!