Skip to content

Instantly share code, notes, and snippets.

@tun
Created February 7, 2013 23:41
Show Gist options
  • Save tun/4735279 to your computer and use it in GitHub Desktop.
Save tun/4735279 to your computer and use it in GitHub Desktop.
Set availability for a full year, except sundays
DECLARE @start_date DATETIME, @end_date DATETIME
SET @start_date = '2014-01-01'
SET @end_date = '2014-12-31'
WHILE @start_date <= @end_date
BEGIN
--PRINT @start_date
IF datepart(weekday, @start_date) = 1
INSERT INTO tblAvailability(avDate, avNumber) VALUES(@start_date, 0)
ELSE
INSERT INTO tblAvailability(avDate, avNumber) VALUES(@start_date, 120)
SET @start_date = DATEADD(DAY, 1, @start_date)
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment