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

Convert Seconds to Time that can be Totaled

Status
Not open for further replies.

eric333

IS-IT--Management
Nov 3, 2007
76
US
I am using the following forumla to convert seconds into time:

NumberVar TotalSec := {VP_TIMESHEETITEM.TIMEINSECONDS};

NumberVar Hours := Truncate ( TotalSec / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);

Totext ( Hours, '####') + ':'+
Totext ( Minutes,'00')

However, I need to be able to total the column, but the Summary options do not allow me to do so. I am okay with having the time displayed as an integer (i.e., 4:30 = 4.50) if that's what it will take.

Any suggestions?
 
Just sum {VP_TIMESHEETITEM.TIMEINSECONDS}, and then divide by 3600, and divide the remainder by 60 as you are doing now.

Also you can dump the variables, they are not needed.

Formula at the record level:
ToText(Truncate({VP_TIMESHEETITEM.TIMEINSECONDS}/3600),'####')&":"&ToText(Truncate(Remainder({VP_TIMESHEETITEM.TIMEINSECONDS},3600/60),'00')

Formula at the total level:
ToText(Truncate(Sum({VP_TIMESHEETITEM.TIMEINSECONDS})/3600),'####')&":"&ToText(Truncate(Remainder(Sum({VP_TIMESHEETITEM.TIMEINSECONDS}),3600/60),'00')


Software Sales, Training, Implementation and Support for Macola, Synergy, and Crystal Reports. Check out our Macola tools:
 
Thanks for the response. Unfortunately, the formula resulted in an error (missing parenthesis). I added on after "3600/60)", because that's where it seemed to fit.

The formula did not return the correct results. A calculation that resulted in 4:30 is now resulting in 4.00 instead of 4.50.
 
As in your original formula the paren belongs after 3600, not after 3600/60). Note that you must sum the seconds in number form at whatever level you want the results, and then apply the formatting by using totext with or without a variable. That's what dgillz formula is doing, too.

-LB
 
I understand completely and both the detail and summaries are working properly now. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top