Jump to content
  • 0

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



2 answers to this question

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.

Link to comment
Share on other sites

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.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...