• 0

# calculate the number of working days between two dates without weekends and holidays

## Question

Hello,

Is there a solution for calculating the number of working days between two dates without weekends and holidays.

## Recommended Posts

• 0

Firstly, you should have two tables:
1. Source table  with the records, and two fields of these records should be two dates that will set the period.
2. A table where you store holidays dates.

You should create a datapage on the first table and create a Calculated Field on the "Configure Results Page Fields" screen with the following code:

```SELECT (DATEDIFF(dd, [@field:Date1], [@field:Date2]) + 1)
-(DATEDIFF(wk, [@field:Date1], [@field:Date2])*2)
-(
SELECT Count(*) FROM Holidays
WHERE (Date BETWEEN [@field:Date1] AND [@field:Date2])
AND (DATENAME(weekday, Date) != 'Sunday' AND DATENAME(weekday, Date) != 'Saturday')
)```

[@field:Date1] is a start date and [@field:Date2] is an end date, and Holidays is a table with the holidays days.

##### Share on other sites

• 0

Hello!

Here's another post that calculates number of working days excluding weekends and holidays using Application Tasks:

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.