Manage Learn to apply best practices and optimize your operations.

Calculate minutes/hours between 2 times, weekday hours only

Calculate minutes/hours between 2 times, weekday hours only

Try this formula for counting minutes

Disregards weekends and works out time between stHour (e.g. 7 for 7am) and endHour (e.g. 18 for 6pm), which you can set in the code or lookup.

If a call is closed on a weekend sets that to close of the day Friday. Likewise, a call opened on a weekend is thought of as starting first thing Monday.

You could also look up holidays in the directory if you wanted to, & discount the time for those.


checkClosed := @If(Status = "Closed" & @IsDocBeingSaved;"";@Return("")); checkDate := @If(dtOpened > dtClosed;@Return(0);""); stHour := 7; endHour := 18; diffHour := (endHour-stHour) *60; dateClosed := @If(@WeekDay(dtClosed) = 7 ; @TextToTime(""" + @Text(@Date(@Adjust(dtClosed;0;0;-1;0;0;0))) + " " + @Text(endHour) + ":00");@If(@WeekDay(dtClosed) = 1 ; @TextToTime(""" + @Text(@Date(@Adjust(dtClosed;0;0;-2;0;0;0))) + " " + @Text(endHour) + ":00");dtClosed)); dateOpen := @If(@WeekDay(dtDue) = 7 ; @TextToTime(""" + @Text(@Date(@Adjust(dtDue;0;0;2;0;0;0))) + " " + @Text(stHour) + ":00");@If(@WeekDay(dtDue) = 1 ; @TextToTime(""" + @Text(@Date(@Adjust(dtDue;0;0;1;0;0;0))) + " " + @Text(stHour) + ":00");dtDue)); diffHours := ((dateClosed - dateOpen) / 60) ; diffDays := (dateClosed - dateOpen) / 86400 ; strtDay := @Modulo(@Weekday(dateOpen); 7); endDay := @Modulo(@Weekday(dateClosed); 7); tdiffDays := @Round(((diffDays - endDay + strtDay - 8) * 5 / 7 - @Max(-2; -strtDay) - @Min(1; endDay) + 5 - strtDay + endDay)); diffMinend := @If(((@Hour(dateClosed)*60) + @Minute(dateClosed)) > (endHour*60); endHour*60; (@Hour(dateClosed)*60) + @Minute(dateClosed)); diffMinstart := @If((@Hour(dateOpen)*60) + @Minute(dateOpen) < (stHour*60); stHour*60; (@Hour(dateOpen)*60) + @Minute(dateOpen)); diffMins := diffMinend - diffMinstart; daysMinEnd := (@If(((@Hour(dateClosed)*60) + @Minute(dateClosed)) > (endHour*60); endHour*60; (@Hour(dateClosed)*60) + @Minute(dateClosed))) - stHour*60; daysMinStart := endHour*60 - (@If((@Hour(dateOpen)*60) + @Minute(dateOpen) < (stHour*60); stHour*60; (@Hour(dateOpen)*60) + @Minute(dateOpen))); @If(tdiffDays = 0 ;diffMins; @If(tdiffDays = 1;daysMinEnd + daysMinStart; (daysMinEnd + daysMinStart) + ((tdiffDays -1)*diffHour) ));

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close