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.
Author |
Topic |
dzabor
Posting Yak Master
138 Posts |
Posted - 2010-02-10 : 13:10:07
|
I have a date that I need to compare to the previous first day of the previous month.For example for the month of Feb I need the following: dbo.Activity.TRANSACTION_DATE < '01/01/2010' (the 01/01/2010 is the date I am trying to dynamically return for each month)Thanks,dz |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-10 : 13:13:33
|
dbo.Activity.TRANSACTION_DATE < DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
dzabor
Posting Yak Master
138 Posts |
Posted - 2010-02-10 : 13:25:53
|
That worked great! Thanks!!! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-10 : 13:31:04
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-02-11 : 06:51:30
|
I recommend using "Month" rather than "mm" -= avoids confusion / ambiguity with Minute / Millisecondi.e. DATEADD(Month,DATEDIFF(Month,0,GETDATE())-1,0) |
|
|
|
|
|