SQLFilter: Advancing Dates
July 17, 2006 7:37 AM   RSS feed for this thread 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 samstarling to computers & internet (3 comments 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


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 Where is the best beach day tr...   |   Things to do in Greenwich, CT?... Newer »
This thread is closed to new comments.


Related Questions
SQL help November 19, 2007
Need help developing a small relational db June 6, 2007
SQL query to get unique addresses from a list. April 18, 2007
MySQL import question November 2, 2006
How can I replace every occurrence of a drive... April 17, 2004