7 Replies Latest reply on May 15, 2018 9:31 AM by steven huang

# How to calculate business hours/minutes between two dates?

I'm trying to understand how to go about calculating business hours between two dates.

For example if I have a start date of 08/29/2013 15:00:00 and an end date of 08/30/2013 10:00:00. I'd expect that the calculation would return 3.00 hours if business hours are defined as 0900-1700.

Has anyone had to tackle this before, or can someone point me in the right direction?

Thanks! - Jared

• ###### 2. Re: How to calculate business hours/minutes between two dates?

Jared,

I am also looking for the same, you got any solution ?

• ###### 3. Re: How to calculate business hours/minutes between two dates?

Nope - I was unable to find a solution for this, and still need a way to exclude data outside of business hours.

• ###### 4. Re: Re: How to calculate business hours/minutes between two dates?

Hi Jared and Rakhesh,

May be I can provide you a partial solution to get the business hours duration. (8AM to 5PM). It will not exclude weekends/holidays, so you can use the networking days solution link provided by Alex Kerin

```IF Datediff('day',[StartTime],[EndTime])=0 Then
(IF Datepart('hour',[EndTime])>17 then 17 else Datepart('hour',[EndTime]) end)-
(IF Datepart('hour',[StartTime])<8 then 8 else Datepart('hour',[StartTime]) end)
Else
Datediff('day',[StartTime],[EndTime])*9 +
(IF Datepart('hour',[EndTime])>17 then 17 else Datepart('hour',[EndTime]) end)-
(IF Datepart('hour',[StartTime])<8 then 8 else Datepart('hour',[StartTime]) end)
End

```

Sample file attached.

• ###### 5. Re: How to calculate business hours/minutes between two dates?

. Indumon,

Anyway to modify this to have different hours for different days?

We have non-standard business hours. Mon - Fri, 8am to 9pm, Sat - Sun, 10am to 7pm.

Thanks

• ###### 6. Re: How to calculate business hours/minutes between two dates?

Here you go ..My business day starts at 8 AM and ends at 7 PM.. This is hour conversion but you can do a %60 and then divide by 60 to get a hour and minute

• ###### 7. Re: How to calculate business hours/minutes between two dates?

it's an old post, but anyone still has this problem.

Check my solution here.