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

How can I calculate a complicated time difference?

Status
Not open for further replies.

ann1

IS-IT--Management
Jan 23, 2003
11
GB
Hi Everyone
I need some help with this one if possible. I have an SLA contract that I have to report on which allows for a next day 17:00 fix. The contract runs from 08:00 to 17:00 Monday to Friday.
So, an example, if a call is logged at 08:00 on Monday then it does not miss the SLA until 17:01 on Tuesday, but if logged at 17:00 on Monday then it misses the SLA at 17:01 on Tuesday again. So the time difference can vary enormously ... I have a formula that calculates straightforward days and times differences for other SLAs .. but absolutely no idea where to start with this one ... any help would be great!!
 
How about...
datevar dt:= date({table.datefield});
timevar tm:=time(17,0,0);

if hour(tm) > 16 then // If after 4pm then use the next day
dt:=dt + 1;
if dayofweek(dt)=1 then // Sunday
Datetime(dt+1, tm)
else if dayofweek(dt)=6 then //Friday
Datetime(dt+3, tm)
else if dayofweek(dt)=7 then //Saturday
Datetime(dt+2, tm)
else Datetime(dt+1, tm) Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top