2 Replies Latest reply on Dec 17, 2015 7:52 PM by KK Molugu

# How to calculate hours between two dates excluding e.g. saturdays

Hi!

I want to calculate the lead time for a process with a start date-time and an end date-time. The problem is that I want to exclude hours during particular days of the week, the typical case being weekends. However, I would like to be able to exclude other days of the week as well.

Example:

The process starts at 2015-09-18 10:00 and ends at 2015-09-20 16:00 and I want to exclude weekend time --> The result should be 14 hours.

I'm also thinking about the possbility to exclude certain hours of the day, e.g. only taking into account time between 08:00-16:00. The goal really is to sum lead time in the process that occurs during my customers' business hours.

I hope that someone has encountered and solved a similiar problem earlier

Best regards,

Anton

• ###### 1. Re: How to calculate hours between two dates excluding e.g. saturdays

Dear Anton,

As per my understanding , first you need to calculate the weekdays i,e you need to exclude the weekends . And once you get the no of weekdays then you can convert those days into working hours.I am not sure weather it will solve your problem fully or not but at least it will give you a start .

Calculate the Number of Business Days Between Two Dates

### Step 1

In Tableau Desktop, select Analysis > Create Calculated Field.

### Step 2

In the Calculated Field dialog box that opens, enter a name for the field.

In the formula field, type the following, and then click OK:

`DATEDIFF('week',[<Start Date>],[<End Date>])*5`

`+`

`MIN(DATEPART('weekday',[<End Date>]),6)`

`-`

`MIN(DATEPART('weekday',[<Start Date>]),6)`

Where `<Start Date>` and `<End Date>` are the names of date fields in the worksheet.

1 of 1 people found this helpful
• ###### 2. Re: How to calculate hours between two dates excluding e.g. saturdays

Anton:

There was a post done sometime back around similar question. Check this out; How to Calculate Working Minutes- Excluding Weekends and Holidays

..kk