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
 New to SQL Server Programming
 Add months to a date column

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2011-02-03 : 14:13:10
Hello again, for testing purposes, I have a small db with transactions, they are a few months old. I would like to take this column and add months to it so that it's in the current year

2010-07-13 00:00:00.000

So I need a query that will take the column there called Currentdate
and add say 6 months to it.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-03 : 14:18:33
DATEADD(MONTH, 6, CurrentDate)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-03 : 14:18:41
SET CurrentDate = dateadd(m,6,Currentdate)

Jim

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

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2011-02-08 : 16:27:09
I entered this as a query but i get an error message

select dbo.transactions
set currentdate=dateadd(month,6,currentdate)

it doesn't like the =
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2011-02-08 : 16:36:29
Sorry about that i have fixed the issue. Thanks for your responses.
Go to Top of Page
   

- Advertisement -