I have a DateTime field in SQL Server for some products expiration (ExpirationDate). I need to increment all the items manually, and set their expiration a month later than the date stored in the field currently. How can I do that?
+9
A:
I don't have SQL Server on my computer, so I cannot test, but what about using DATEADD
, a bit like this :
update your_table set your_field = DATEADD(month, 1, your_field)
Pascal MARTIN
2009-09-10 19:27:54
I'm pretty sure you mean to say update your_table, fixed it for you.
RedFilter
2009-09-10 19:30:40
@OrbMan : ergh, yes, of course :-( Thanks for the edit !
Pascal MARTIN
2009-09-10 19:31:55
Thanks guys, really helpful! I appreciate it.
Cristi Cotovan
2009-09-10 19:32:34
+9
A:
UPDATE Products SET ExpirationDate=DATEADD(month,1,ExpirationDate) WHERE Type='Cheese'
Jonas Elfström
2009-09-10 19:28:38