I need to calculate Number of INCLUDING Weeks (even if only 1 day falls in the next week (weeks starts on Monday, ends on Sunday), count it as the week as well) between 2 dates.
If I use regular datediff, the output for both is 2.
SELECT datediff(ww, '2022-03-01','2022-03-13')
SELECT datediff(ww, '2022-03-14','2022-03-31')
But I need to get 2 and 3 number of weeks instead:
From Date | To Date | Expected |
---|---|---|
2022-03-01 | 2022-03-13 | falls in 2 weeks (02/28/2022 - 03/06/2022 and 03/07/2022 - 03/13/2022) |
2022-03-14 | 2022-03-31 | falls in 3 weeks (03/14/2022 - 03/20/2022, 03/21/2022 - 03/27/2022 and 03/28/2022 - 04/03/2022) |