Home Forums Article Discussions Article Discussions by Author Discuss content posted by Divya Agrawal Finding the Correct Weekday Regardless of DateFirst RE: Finding the Correct Weekday Regardless of DateFirst
Patrick Dekkers
SSC Enthusiast
Points: 115
More actions
February 19, 2010 at 2:02 am
#1121622
Thanks for putting me in the right direction.
If you want Monday to be day 1 and Sunday to be day 7 use this:
SELECT ((DATEPART(dw, '2010-02-23') + @@DATEFIRST -2) % 7)+1 AS dw
There's no day 0.