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)
 adding months but subtracting day

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2010-05-25 : 12:52:32
what's wrong with this?

select dateadd(d,-1,(dateadd(mm, 24,
getdate()))

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2010-05-25 : 13:02:04
??

select dateadd(d,-1,dateadd(mm, 24,getdate()))


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-05-25 : 13:03:22
You're missing a )

select dateadd(d,-1,
(dateadd(mm, 24,
getdate()
)
)
)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-25 : 13:04:00
select dateadd(d,-1,(dateadd(mm, 24,getdate())))


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-25 : 13:04:41



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-26 : 04:15:12
It can be simplified to


select dateadd(month, 24,getdate()-1)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -