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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seconds to dd:hh:mm:ss

Status
Not open for further replies.
Jul 11, 2003
19
CA
All

I know that one of the FAQ's does have a formula like this:

whileprintingrecords;

numberVar dur:={TIME_TO_FINISH}(this is where error occurs)
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs, "0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

hhmmss

but it is not working for me. I get error that from the point indicated in the above code, it gives me "the remaining text is not part of the formula.

Also, I tried getting it to display dd:mm:hh:ss, but I just can't get it to work. Has someone else got this? TIA

Trent - using Crystal 8.5
 
numberVar dur:={TIME_TO_FINISH}[COLOR=red yellow];[/color] //(this is where error occurs)


Kingfisher
 
Here is an adaptation of Synapsevampire's conversion formula that adds in days.

numberVar dur := {TIME_TO_FINISH}; //assuming field is in seconds
numberVar days;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar ddhhmmss;

days := Truncate(dur/86400);
hrs := Truncate(Remainder(dur,86400)/3600);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

ddhhmmss := totext(days,"00")+ ":"+totext(hrs, "00") + ":" +
totext(min, "00") + ":" + totext(sec, "00");

ddhhmmss;

-LB

 
LB & KingfisherINC,

I figured it out after a few rounds of trial and error, but thanks all the same, it helped me clean mine up. Another addition to the knowledge base I suppose. :)

Thanks again!

-TS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top