First Sunday of given Month

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 1196
DECLARE @MonthNumber int = 10 -- Month Number 
SELECT DATEADD(dd,(DATEDIFF(dd,0,DATEADD(mm,@MonthNumber-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))/7 * 7 )+6,0)


Output:
2015-10-04 00:00:00.000

Comments or Responses

Login to post response