Reputation: 11
I am charged with the task of solving a scenario based on the following: The database server had been reset with the wrong date and time without anyone knowing. UPDATE any order date in the past week to add 7 days.
The Orderdate is stored in ORDERS.ORDERDATE. I tried using the following code and it fails:
UPDATE ORDERS
SET ORDERDATE,DATEADD(day,7,OrderDate)
WHERE DATEDIFF >= (
DAY,
DATEDIFF(DAY, @ORDERDATE, -7),
GETDATE());
Can someone provide me with the proper code?
Any assistance is appreciated!
Upvotes: 1
Views: 1288
Reputation: 522084
Your syntax appears to be for SQL Server, but you tagged the question for Oracle. In any case, a correct UPDATE
query in Oracle should look something like this:
UPDATE ORDERS
SET ORDERDATE = ORDERDATE + INTERVAL '7' DAY
WHERE ORDERDATE > SYSDATE - INTERVAL '7' DAY
Here SYSDATE
is a DATE
object representing the current date and time.
Upvotes: 2
Reputation: 913
You can maybe try with
Update ORDERS
SET ORDERDATE = ORDERDATE + 7
WHERE SYSDATE - ORDERDATE <= 7;
Upvotes: 1