I need a formula that will calculate our open and close times in hours not days. This is the formula I am using:
DateTimeVar Start := {Help_Desk.Open Date & Time}; //Replace this field with your Starting Date field
DatetimeVar End := {Help_Desk.Close Date & Time}; //Replace this field with your Ending Date field
NumberVar Hours;
NumberVar Weeks;
NumberVar Days;
NumberVar Hol:= 0;
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;
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(2001,11,22) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2001,11,23) in start to end then Hol:= Hol+1 else Hol:= Hol;
Weeks + Days - Hol
It is accurate in days, but I need actual hours.
DateTimeVar Start := {Help_Desk.Open Date & Time}; //Replace this field with your Starting Date field
DatetimeVar End := {Help_Desk.Close Date & Time}; //Replace this field with your Ending Date field
NumberVar Hours;
NumberVar Weeks;
NumberVar Days;
NumberVar Hol:= 0;
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;
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(2001,11,22) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2001,11,23) in start to end then Hol:= Hol+1 else Hol:= Hol;
Weeks + Days - Hol
It is accurate in days, but I need actual hours.