Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting decimal to time display 1

Status
Not open for further replies.

wilbur00

Programmer
Dec 9, 2004
16
US
Hello -

(Crystal 10, SQL Server)

I've done some time calculations which give me a decimal value in hours (e.g. 1.25 = 1 hour 15 minutes). Now I'm trying to display that value on a report as hh:mm:ss (e.g. 01:15:00). What is the correct function and format of the function to use?

Thank you!
 
This will display your decimal time in hh:mm:ss format as a string.

whileprintingrecords;
numbervar tim := {time.field};
totext(time(dateadd("s",tim*3600,datetime(0,0,0,0,0,0))),"HH:mm:ss")


If you want the field to be a time,use the following and format the field to show hh:mm:ss (make sure it's in 24hour format)

whileprintingrecords;
numbervar tim:= {time.field};
time(dateadd("s",tim*3600,datetime(0,0,0,0,0,0)))


Mike
 
First of all, thank you for your responses. I am still having troubles though...

My call duration field (@NumCallDurationMain) contains 1.673333 hours (which is 1 hour and 40 minutes)

I converted it to seconds and got 6024
{@NumCallDurationMain}*3600

When I use the following to convert it to a time display, I get 00:00:65. I'd like to show 01:40:00.

totext(time(dateadd("s",{@NumCallDurationMain}*3600,datetime(0,0,0,0,0,0))), "HH:mm:ss")

Your assistance is much appreciated!
 
See synapsevampire's faq767-3543.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top