Skip to content

Instantly share code, notes, and snippets.

@vcsjones
Created January 4, 2013 21:57
Show Gist options
  • Save vcsjones/4457406 to your computer and use it in GitHub Desktop.
Save vcsjones/4457406 to your computer and use it in GitHub Desktop.
CTE to query the business days of the current week.
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