Burak Inan
Burak Inan

Reputation: 5

SQL add 1 day to all dates between two values

Statement: Rides between 20-12-2016 and 31-12-2016 are delayed one day. How do I write the SQL query for this?

I currently have:

UPDATE Rides
SET (SELECT * FROM Rides WHERE Date BETWEEN '20-12-2016' AND '31-12-2016') = [SOMETHING]

Upvotes: 0

Views: 87

Answers (2)

Grayson
Grayson

Reputation: 601

This works in Oracle:

UPDATE rides
  SET date_field = date_field + 1
  WHERE date_field BETWEEN '2016-12-20' AND '2016-12-31';

I refer to the field to update as date_field since it is a bad practice to name fields/columns with a reserved keyword.

Upvotes: 3

Siyual
Siyual

Reputation: 16917

You can use the following for Oracle:

Update  Rides
Set     Date = Date + 1
Where   Date Between '2016-12-20' And '2016-12-31'

Upvotes: 2

Related Questions