Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 last wednesday date from a given date

Author  Topic 

Starting Member

1 Post

Posted - 2011-12-04 : 01:55:15
please let me know how to find last wednesday date

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-04 : 02:01:57
below will give you last wednesday

select dateadd(dd,datediff(dd,0,getdate())/7 * 7 + 2,0)

if you replace getdate with any date you will get previous wednesday from that date

select dateadd(dd,datediff(dd,0,'2011-11-14')/7 * 7 + 2,0)

SQL Server MVP

Go to Top of Page

Aged Yak Warrior

819 Posts

Posted - 2011-12-04 : 09:16:58
This also works:

Select datename(weekday, 2)
,dateadd(week, datediff(week, 2, getdate()) - 1, 2);

Change the '- 1' to any value to go back/forward that number of weeks.

Go to Top of Page

- Advertisement -