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) ));
```

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### December Patch Tuesday resolves Windows zero-day

Microsoft delivers the final batch of security fixes for the year with a Windows zero-day vulnerability getting top billing for ...

Microsoft put its branding on a relatively new hyper-converged infrastructure offering that capitalizes on the software-defined ...

• ### How to manage Exchange hybrid mail flow rules

Duplicating your existing transport rule collection won't work when you move to an Exchange hybrid deployment. Learn how to set ...

## 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

• ### Refresh your data center cooling lexicon

As the data center industry moves to improve energy efficiency, refresh your knowledge on the available cooling technology and ...

• ### Comparing Linux distributions: Red Hat vs. Ubuntu

Before selecting a Linux distribution, compare Red Hat Enterprise Linux and Ubuntu when it comes to features, ease of use, ...

• ### Get eco-friendly with LEED data center certification

The U.S. Green Building Council helps companies make existing and new data centers eco-friendly. HVAC, lighting and monitoring ...

## SearchContentManagement

• ### DNA as a content storage device is closer than you think

Storing content in DNA may one day be possible, but today, it's neither practical nor cost-effective. Here's where this ...

• ### Acquia acquisition of AgilOne CDP signals CX platform expansion

Acquia's acquisition of AgilOne, a customer data platform specializing in analytics, shows it's serious about competing against ...

• ### Personalization engines help engage and retain customers

Content personalization is essential to getting the right material to the right customers. Here are some personalization engines ...

Close