Hi there,
I am making use of Ken Hamady's formula that calculates the number of business hours between two dates (see FAQ, Common Formula Examples) and it works great until we have the exception date-time that is outside of the normal business hours. Then it results in a negative time.
I have tried to customize Ken's formula to account for the times that are outside, but I get a syntax error.
Here is the formula;
if TimeValue({HD_INCIDENT.LOGGED_DT}) < TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) < TimeValue("17:00:00"
then
TimeVar SetStart := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar SetEnd := TimeValue("17:00:00"
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
else if TimeValue({HD_INCIDENT.LOGGED_DT}) >= TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) >= TimeValue("17:00:00"
then
TimeVar SetStart := TimeValue("7:30:00"
TimeVar SetEnd := TimeValue({HD_INCIDENT.ASSIGN_DT})
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
else if TimeValue({HD_INCIDENT.LOGGED_DT}) < TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) >= TimeValue("17:00:00"
TimeVar SetStart := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar SetEnd := TimeValue({HD_INCIDENT.ASSIGN_DT})
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
numberVar HoursElapsed:=
Days * ((SetEnd - SetStart) / 3600)
- ((SetEnd - EndTime) / 3600)
- ((StartTime - SetStart) / 3600);
I'm confused about the semi-colon placement in the nested if statements...
I am making use of Ken Hamady's formula that calculates the number of business hours between two dates (see FAQ, Common Formula Examples) and it works great until we have the exception date-time that is outside of the normal business hours. Then it results in a negative time.
I have tried to customize Ken's formula to account for the times that are outside, but I get a syntax error.
Here is the formula;
if TimeValue({HD_INCIDENT.LOGGED_DT}) < TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) < TimeValue("17:00:00"
then
TimeVar SetStart := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar SetEnd := TimeValue("17:00:00"
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
else if TimeValue({HD_INCIDENT.LOGGED_DT}) >= TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) >= TimeValue("17:00:00"
then
TimeVar SetStart := TimeValue("7:30:00"
TimeVar SetEnd := TimeValue({HD_INCIDENT.ASSIGN_DT})
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
else if TimeValue({HD_INCIDENT.LOGGED_DT}) < TimeValue("7:30:00"
and TimeValue({HD_INCIDENT.ASSIGN_DT}) >= TimeValue("17:00:00"
TimeVar SetStart := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar SetEnd := TimeValue({HD_INCIDENT.ASSIGN_DT})
TimeVar StartTime := TimeValue({HD_INCIDENT.LOGGED_DT})
TimeVar EndTime := TimeValue({HD_INCIDENT.ASSIGN_DT})
numberVar HoursElapsed:=
Days * ((SetEnd - SetStart) / 3600)
- ((SetEnd - EndTime) / 3600)
- ((StartTime - SetStart) / 3600);
I'm confused about the semi-colon placement in the nested if statements...