I am using SQL Server 2008, in this I can get weekday of today as
select datepart(weekday, GETDATE()) WeekDay
and it will be returning 5 as weekday. I need to subtract 1 from this, i.e. 5-1 = 4.
Here’s what I’ve tried:
select dateadd(weekday, -1, datepart(weekday, GETDATE())) WeekDay
but it is returning 1900-01-05 00:00:00.000
Why am I not getting 4 and why is it showing this date? Can anyone explain this?
Thanks in advance.
This will surely returns 4.