T-SQL to Display Weekends Between two Dates
T-SQL to Display Weekends Between two Dates
Different ways to find the weekend between two given dates.
DECLARE @beginDate Date='20150101', @endDate Date='20150131' DECLARE @Calendar Table (CalendarDate Date Primary key, IsWeekend Bit) WHILE @beginDate <= @endDate BEGIN INSERT INTO @Calendar SELECT @beginDate As CalendarDate ,(Case When DATEPART(Weekday, @beginDate) In (7, 1) Then 1 Else 0 End) As IsWeekend Set @beginDate = DateAdd(Day, 1,…
View On WordPress












