Created
January 4, 2013 21:57
-
-
Save vcsjones/4457406 to your computer and use it in GitHub Desktop.
CTE to query the business days of the current week.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET DATEFIRST 1; | |
WITH [week]([date]) AS | |
( | |
SELECT | |
DATEADD(week, DATEDIFF(week, 0, GETDATE()), 0) | |
UNION ALL | |
SELECT | |
[date]+1 FROM [week] | |
WHERE | |
DATEPART(dw, [date]+1) <= 5 | |
) | |
SELECT * FROM [week]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment