Calculate Due TIME

I am developing a helpdesk system, where I want the Due Date to reflect as soon as I enter the Severity levelSev 1: 2 business hours to resolve

Sev 2: 5 business hours to resolve

Sev 3: 10 business hours to resolve

Sev 4: Due Date driven - HelpDesk Operator can set this date.

How do I only include business hours (8am-5pm) and Business days in this equation?

Or if anyone has a solution, or suggestions, please help!

I found 2 pieces on this forum :


Calculate End Date w/start date and set number of business days excluding holidays and weekends

Posted by Patti Albracht on 14.Jan.05 at 11:45 AM using a Web browser

Category: Domino DesignerRelease: 6.0.2 CF2Platform: Windows XP

 

I was looking for a post to calculate an end date with the known items being the starting date and the holidays and a set number of business days. I didn't find anything, but I came up with a simple solution.



Field = Holidays - Text multiple mm/dd/yyyy

Field = StartDate - Date

Field = EndDate

Button to calculate end date.



Button code:



CurrDate:=StartDate;

BusinessDays:=0;

TotalDays:=0;

n:=0;

@DoWhile(

CurrDate:=@Adjust(CurrDate;0;0;1;0;0;0);

TotalDays:=TotalDays+1;

BusinessDays:=@If((@Weekday(CurrDate) = 1 | @Weekday(CurrDate) = 7) | @IsMember(@Text(CurrDate; "D0S0"); Holidays); BusinessDays; BusinessDays + 1);



@If(BusinessDays=10; 0; 1)

);

FIELD EndDate := CurrDate; 



Calculating # of Business Hours between two dates/times

Posted by Adam Fenstermaker on 6.Oct.04 at 10:15 AM using a Web browser

Category: Domino DesignerRelease: All ReleasesPlatform: All Platforms

I’ve been in need of this formula in the past to measure turnaround and have always done it with LotusScript. I was trying to find a post in the forum or the sandbox that used the new R6 @BusinessDays that did this - so when I didn’t here’s what I came up with - please respond if you find bugs - hopefully it prevents someone else from re-creating the wheel.

REM {INITIALIZE VARIABLES};

_StartDate := @Date(IP_Date_Requested);

_StartTime := @Time(IP_Time_Requested);

_EndDate := @Date(IP_Date);

_EndTime := @Time(IP_Time);

_HolidayList := [12/25/04];

REM {ADJUST TIMES TO NOT COUNT HOURS BEFORE 8 OR AFTER 5};

_StartTime := @If(_StartTime - [8:00 AM] < 0;[8:00 AM];_StartTime - [5:00 PM] > 0; [5:00 PM];_StartTime);

_EndTime := @If(_EndTime - [8:00 AM] < 0;[8:00 AM];_EndTime - [5:00 PM] > 0; [5:00 PM];_EndTime);

REM {DETERMINE # OF BUSINESS DAYS IN DATE RANGE};

_BusinessDays := @BusinessDays(_StartDate;_EndDate;1:7;_HolidayList);

_StartDayIsBiz := @BusinessDays(_StartDate;_StartDate;1:7;_HolidayList);

_EndDayIsBiz := @BusinessDays(_EndDate;_EndDate;1:7;_HolidayList);

REM {CALC # OF BUSINESS DAYS BETWEEN DATES};

_DaysBetween := _BusinessDays - _StartDayIsBiz - _EndDayIsBiz;

REM {ASSUME 9 HOURS IN BUSINESS DAY - 8:00 AM TO 5:00 PM};

_HoursBetween := @If(_DaysBetween > 0;_DaysBetween * 9;0);

REM {CALCULATE # OF BUSINESS HOURS IN FIRST DAY};

_StartDayHours := @If(_StartDayIsBiz = 0;0;

_EndDate - _StartDate = 0;(_EndTime - _StartTime)/3600;

([5:00 PM] - _StartTime)/3600

);

REM {CALCULATE # OF BUSINESS HOURS IN LAST DAY};

_EndDayHours := @If(_EndDayIsBiz = 0;0;

_EndDate - _StartDate = 0;0;

(_EndTime - [8:00 AM])/3600

);

@Round(_StartDayHours;0.1) + _HoursBetween + @Round(_EndDayHours;0.1);




I just cannot seem to get the 2 together?

Please help!

Subject: Calculate Due TIME

or you can just write 25 if statements. its not the cleanest code but it will do the job.

ST

Subject: Calculate Due TIME

Small world. I’m doing the same thing today.

This might not help because it’s LotusScript, but I post it in case it helps someone else. I’m using it in a sub in a script library. It seems to work; if I come up with any refinements during testing over the next couple of days, I’ll post them.

'Initial values:

’ n = number of minutes to resolve the particular ticket

’ dtstart: set to Now

’ dtdue: set to Now, initially

’ dteod : set to Today, 5:00 pm

’ dtsod : set to Today, 8:00 am

'Then reset dtdue based on value of n, time of day and day of week (to count only business hours)

'Note TimeDifference returns time in seconds, whereas n is in minutes

If dteod.TimeDifference(dtstart) < n * 60 Then

 'the number of minutes until due exceeds number of minutes left in business day

 'so move up the day to next day and count the minutes again

 While (dteod.TimeDifference(dtstart) < n * 60 Or Weekday(dteod.LSLocalTime) = 1 Or Weekday(dteod.LSLocalTime) = 7)

 'From n, subtract the number of minutes left in the current business day.

      n = n - (dteod.TimeDifference(dtdue)/60)

      'Then reset dtdue to start of next business day plus the remaining minutes.

      Call dtsod.AdjustDay(1)  'to 8:00 am next day

      Set dtdue = dtsod

      Call dtdue.AdjustMinute(n)

      Call dteod.AdjustDay(1)  'to 5:00 am next day, in case we have to loop again

      iday = iday + 1

      If iday > 5 Then

           Msgbox "infinite loop - exit sub now"  'safety feature

           Exit Sub

      End If

 Wend

Else

'the number of minutes until due is less than the number of minutes left in business day

'so add n to dtdue

 Call dtdue.AdjustMinute(n)

End If

Hope that helps.