How to find week of the Year,start date and end date of the week in SQL Server


Below Script gives you three important details related to date using datepart() function.

Current Week of the Year
Start of Week Date
End of Week Date

when we will execute the below script we will get the output like below:-

SELECT DATEPART( WeeK, SYSDATETIME()) 'Current Week of the Year',
CONVERT(VARCHAR(15), DATEADD(dd, -(DATEPART(dw, SYSDATETIME())-1), SYSDATETIME()),101) 'Start of Week Date',
CONVERT(VARCHAR(15), DATEADD(dd, 7-(DATEPART(dw, SYSDATETIME())), SYSDATETIME()),101) 'End of Week Date'


 

Leave a Reply

Your email address will not be published. Required fields are marked *