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

Hours to Days conversion 1

Status
Not open for further replies.

szed

Programmer
Jun 25, 2003
55
US
I am using Crystal 10 and Oracle 9i.

I have a formula that calculates the hours of a date difference, minus any weekends that fall in between. I copied it off this website from a previous post, and it is pretty lengthy. It takes into consideration 1/2 days, and everything else you can run into when calculating time difference minus weekends. This formula is returning hours and minutes.

What I need is to show a Day:Hour:Minute conversion for this. I can get the minutes from the hours but I am having a hard time trying to convert the hours into days and subtracting those hours from the hours.
For example I have one that is showing
HH:MM
41:07

I need it to show
DD:HH:MM
1:17:07

I can get the 1 day to show up but it will still show the 41 hours, 1:41:07.
How do I convert it back and subtract that 24 hours from the hour figure?
 
stringvar a:="41:07"; //replace the "41:07" with your field
numbervar days;
numbervar hrs;
stringvar mins;
days:= int((tonumber(left(a,instr(a,":")-1)))/24);
hrs:=(tonumber(left(a,instr(a,":")-1))-(days*24));
mins:=right(a,2);
totext(days,0,"") + ":" + totext(hrs,0,"")+":" + mins;

//this will display (for the above value) 1:17:07
 
Thanks so much stevefah, that worked perfectly!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top