Please start any new threads on our new site at https://forums.sqlteam.com. 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
 How to get previous year, previous month's date

Author  Topic 

kishoremcp
Starting Member

41 Posts

Posted - 2013-09-10 : 05:07:23
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-10 : 09:08:59
[code]DATEADD(mm,DATEDIFF(mm,0,GETDATE())-13,0)[/code]
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-10 : 09:20:02
Dup of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=188086
Go to Top of Page
   

- Advertisement -