How do I increase a DateTime field in SQL Server 2005 by a month?
I have a DateTime field in SQL Server for Products Expiration (ExpirationDate). I need to increment all items manually and set them to expire one month after the date currently stored in the field. How can i do this?
+2
Cristian Cotovan
source
to share
2 answers
I don't have SQL Server on my machine, so I can't check, but what about using DATEADD
, a bit like this
update your_table set your_field = DATEADD(month, 1, your_field)
+10
Pascal MARTIN
source
to share
UPDATE Products SET ExpirationDate=DATEADD(month,1,ExpirationDate) WHERE Type='Cheese'
+9
Jonas Elfstrรถm
source
to share