Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

t sql list week start date and end date for a year

DECLARE @Date1 DATE, @Date2 DATE
SET @Date1 = DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
SET @Date2 = DATEADD(yy, DATEDIFF(yy,0,getdate()) + 1, -1)

SELECT DISTINCT dateadd(ww, datediff(ww, 0,DATEADD(DAY,number+1,@Date1)), 0) [StartDate],
				dateadd(ww, datediff(ww, 0,DATEADD(DAY,number+1,@Date1)), 6) [EndDate]
FROM master..spt_values
WHERE type = 'P'
AND DATEADD(DAY,number+1,@Date1) < @Date2
 
PREVIOUS NEXT
Tagged: #sql #list #week #start #date #date #year
ADD COMMENT
Topic
Name
5+5 =