How to get Week First and Last day and also running week Number using Sql server

    Using sql server Get Today Week no of day and Fist and Last day of week

 Select GETDATE() AS 'Today', DATEPART(Week,GETDATE()) AS 'Week No of Today', 
DATEADD(DAY , -DATEPART(WEEKDAY,(DATEADD( DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE())))
+ (7-DATEPART(WEEKDAY,GETDATE()))+1 ,GETDATE()) 'First Day Of This Week',
DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE()) AS 'Last Day Of Week'



Getdate()  returns today's date

datepart(week,getdate()) returns current week no



Ebook Download
View all
Learn
View all