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?
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?
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
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
This thread is closed to new comments.
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