John John - 5 months ago 9
SQL Question

Update the date in the database with +1 month

I have a date column in my users what I want to update with a SQL query

With the SQL query I want to add 1 month to date column in my database.

I now have:

UPDATE users SET date=(+ 1 month)


When I run this query it is not working. So my question is, how can I make this working?

Answer

You never told us the database you are using, so here are several answers:

MySQL:

UPDATE users
SET date = DATE_ADD(date, INTERVAL 1 month )

SQL Server:

UPDATE users
SET date = DATEADD(MONTH, 1, date)

Oracle:

UPDATE users
SET date = ADD_MONTHS(date, 1)