Getting First Sunday of a Month.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 243
DECLARE @MonthNumber int = 12 --December

SELECT DATEADD(dd,(DATEDIFF(dd,0,DATEADD(mm,@MonthNumber-1,
DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)))/7 * 7 )+6,0) AS SUNDAY
Output:-2014-12-07 00:00:00.000

Comments or Responses

Login to post response