SQLFilter: Advancing Dates
July 17, 2006 7:37 AM   Subscribe

How can I increment a value directly using SQL?

I have several tables containing dates, and I want to be able to advance these dates by x days. Can I do an UPDATE in SQL which will find the date in question and add on x number of days? Having said that though, the database is in Access - would it be easier to use something within Access to do this?
posted by xvs22 to Computers & Internet (3 answers total)
 
This should work. I'm pretty sure DATEADD works in Access:

UPDATE TABLENAME SET datefield = DATEADD(d, x, datefield)

... where X is the number of days you want to add to the date.
posted by Doofus Magoo at 7:44 AM on July 17, 2006


DateAdd is what you want.
posted by twiggy at 7:52 AM on July 17, 2006


Best answer: Don't forget the single quotes and the where clause (if necessary):

UPDATE TableName SET dateField = DATEADD('d',X,dateField) WHERE dateField=MyDate

MyDate = the date you are searching for
posted by SoulOnIce at 8:14 AM on July 17, 2006


« Older Best day trip beach from Orlando?   |   Things to do in Greenwich, CT? Newer »
This thread is closed to new comments.