I know this has been answered in some posts but my requirement is rather different.
What I want is to count all weekdays within range which will include start date and end date. For example:
@s = 2017-05-15, @e = 2017-05-30
using this query (which i found on here):
5 * (DATEDIFF(@E, @S) DIV 7) + MID('0123444401233334012222340111123400001234000123440', 7 * WEEKDAY(@S) + WEEKDAY(@E) + 1, 1)
this returns 11 but what I expect is 12:
[15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 29, 30]
maybe either start or end date is not counted?
Anyone have an idea?