Link to home
Start Free TrialLog in
Avatar of boris711
boris711

asked on

Convert Decimal Number to HH:MM:SS

Hello Experts:
We have a FireBird DB from which we're using CR XI to pull a decimal number that represents hours spent on a project.

I'd like to convert this decimal number to appear in my reports in the format of:  "HH:MM:SS" (without any reference to AM/PM, as that is irrelevant)

But I will also need to summarize the column that holds these times into the same format, thus performing math on the converted numbers. (without conversion to days at HH > 24.)

Examples:
Decimal Hours= Desired result
0.03 = 00:01:48
2.25 = 02:15:00

Summarized as:
02:16:48

I'm sure I can work out the math, multiplying the initial decimal by 3600 for total SS, and working my way from there to MM and HH, but am wondering if there is a shorter method within CR XI.

TIA!


 
Avatar of Marcus Aurelius
Marcus Aurelius
Flag of United States of America image

CR has a function called TIME(number)
the number can be decimal
Use a forumla to convert the field(type number) to type time
Then use the fomula where ever required.

ex: 2.83 converts to  7:55:12PM
    18.87 converts to  8:52:48PM


You might use CTime because you can only use Time in Crystal syntax as it is a type name in Basic syntax.

CTime (number) converts the given number to a Time value; the given number is in units of 24 hours, can be fractional or negative as well.

Hope it helps
MikeV
ASKER CERTIFIED SOLUTION
Avatar of KENNETH TURNER
KENNETH TURNER

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of boris711
boris711

ASKER

While neither comment hit exactly what I was looking for KenTurner's gave me a new perspective. Thank you both for responding.