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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 last wednesday date from a given date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 12/04/2011 :  01:55:15  Show Profile  Reply with Quote
please let me know how to find last wednesday date

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 12/04/2011 :  02:01:57  Show Profile  Reply with Quote
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 - 12/04/2011 :  09:16:58  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000