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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 One Month from getdate() and Day 1
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ph1long
Starting Member

16 Posts

Posted - 12/03/2012 :  12:58:05  Show Profile  Reply with Quote
Hi,

Please help. I would like a query that would get me a month prior to today's date and start with day 1. For example,if today's date was 11/23/2012. My end result would be 10/1/2012.

Thanks

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/03/2012 :  14:21:41  Show Profile  Reply with Quote
DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
Go to Top of Page

ph1long
Starting Member

16 Posts

Posted - 12/04/2012 :  10:40:00  Show Profile  Reply with Quote
Thanks. It worked.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/06/2012 :  01:34:25  Show Profile  Reply with Quote
see the logic behind here

http://visakhm.blogspot.in/2012/07/generate-datetime-values-from-integers.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.09 seconds. Powered By: Snitz Forums 2000