In the second table I have to update aeging column value to difference between reqDate column in tbl2 and enddate excluding sundays and the holidays which fall between these two dates.
aeging reqDate
151 2019-07-01 00:00:00.000
151 2019-07-01 00:00:00.000
150 2019-07-02 00:00:00.000
150 2019-07-02 00:00:00.000
134 2019-07-21 00:00:00.000
128 2019-07-29 00:00:00.000
114 2019-08-16 00:00:00.000
100 2019-09-01 00:00:00.000
4 2019-12-24 00:00:00.000
For example the difference between the number of days between 1st july and 29 december excluding sunday was 156 and in between there were 5 holidays so subtracting 5 holidays we get 151.
I have subtracted the number of sundays.Using this query
Update tbl2 set aeging=(DATEDIFF(dd, tbl2 .reqDate, @enddate) + 1)-(DATEDIFF(wk, tbl2 .reqDate, @enddate) * 1)
-(CASE WHEN DATENAME(dw, tbl2 .reqDate) = 'Sunday' THEN 1 ELSE 0 END)
But how should i subtract number of public holidays between these two dates? what query should i writes i am stuck on this kindly let me know the solution