SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 How to get previous year, previous month's date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kishoremcp
Starting Member

India
39 Posts

Posted - 09/10/2013 :  05:07:23  Show Profile  Reply with Quote
Hi,

I am new to sql server. I want a sql query to get previous year's previous months first day everytime.

Example: If i run the query on 9/10/2013 (MM/DD/YYYY) then it should give 8/1/2012.

Please let me know how..


Also help me with any documentations to know about queries. Any PDF files kind of thing.

Thanks in advance.



Regards
Kishore

James K
Flowing Fount of Yak Knowledge

3707 Posts

Posted - 09/10/2013 :  09:08:59  Show Profile  Reply with Quote
DATEADD(mm,DATEDIFF(mm,0,GETDATE())-13,0)
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3707 Posts

Posted - 09/10/2013 :  09:20:02  Show Profile  Reply with Quote
Dup of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=188086
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.27 seconds. Powered By: Snitz Forums 2000