How to find the Date is first day of the Week in SQL

Some time you may need to find the given date is first day of the week or not? here is the code.

IF DATEPART(DW,GETDATE()) = @@DATEFIRST 
BEGIN 
PRINT CONVERT(VARCHAR,GETDATE(),110) + ' IS FIRST DAY OF THE WEEK'
END
ELSE 
BEGIN
PRINT CONVERT(VARCHAR,GETDATE(),110) + ' IS NOT A FIRST DAY OF THE WEEK'
END

Leave a Reply

Your email address will not be published.