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!

Converting a number into hours and minutes

Status
Not open for further replies.

ejerblom

Technical User
Sep 22, 2003
10
SE
Hi,

Does anyone know how to convert a number into hours and minutes? The following code generates a number for example 1.42:

WhilePrintingRecords;
NumberVar Days := {@Weekends and holidays}; // The field that calculates your business days
TimeVar SetStart := TimeValue("00:00"); // The start your work day
TimeVar SetEnd := TimeValue("23:59"); // The end your work day
TimeVar StartTime := TimeValue({Incident.ReportedDate});// The data field that holds your Start Time
TimeVar EndTime := TimeValue({Incident.ResolvedDate}); // The data field that holds your End Time

Days * ((SetEnd - SetStart) / 3600)
- ((SetEnd - EndTime) / 3600)
- ((StartTime - SetStart) / 3600)

How can the result be presented in hours and minutes?

Regards
Ulrika
 
I took a look at the code (FAQ767-3543) and I still have one problem. I also need to exclude weekends and holidays. Therefore I have made the following code for this:

WhilePrintingRecords;
DateTimeVar Start := {Incident.ReportedDate}; //Replace this field with your Starting Date field
DateTimeVar End := {Incident.ResolvedDate}; //Replace this field with your Ending Date field
NumberVar Weeks;
NumberVar Days;
NumberVar Hol:= 0;

//Figure the number of Calendar "Rows" involved and count 5 days for each:
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;

//Adjust the first and last weeks based on when in the week you start and end
Days := DayOfWeek(End) - DayOfWeek(Start) + 1
+ (if DayOfWeek(Start) = 1 then -1 else 0) //adjust for starting on a Sunday:
+ (if DayOfWeek(End) = 7 then -1 else 0); //adjust for ending on a Saturday:

//Adjust for Holidays in the period between the start and end dates:
if Date(2003,12,24) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2003,12,25) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2003,12,26) in start to end then Hol:= Hol+1 else Hol:= Hol;

//Assemble the adjusted work days
Weeks + Days - Hol

Can I exclude weekends and holidays in the suggestedcode FAQ767-3543?

Or is there a posibility to convert the outcome of my first code to hours and minutes i.e is it possible to convert 1.42 to 1.25 (hours and minutes)

/Ulrika
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top