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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 One Month from getdate() and Day 1

Author  Topic 

ph1long
Starting Member

16 Posts

Posted - 2012-12-03 : 12:58:05
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
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-12-03 : 14:21:41
[code]DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)[/code]
Go to Top of Page

ph1long
Starting Member

16 Posts

Posted - 2012-12-04 : 10:40:00
Thanks. It worked.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-06 : 01:34:25
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
   

- Advertisement -