I had a column with dates, in an Select
statement, and i want to add 2 h to each row in this Select
.
Any advice?
I had a column with dates, in an Select
statement, and i want to add 2 h to each row in this Select
.
Any advice?
I prefer using interval
for this:
select deliverydate + interval '2' hour
from the_table;
The above is standard SQL and works well in Oracle.
More details in the manual: https://docs.oracle.com/database/121/SQLRF/sql_elements003.htm#SQLRF00221
UPDATE Table1 AS t2 INNER JOIN Table1 ON t2.ID = Table1.ID
SET Table1.DeliveryDate = DateAdd("h",2,[t2].[DeliveryDate]);
UPDATE Table1 AS t2 INNER JOIN Table1 ON t2.ID = Table1.ID
SET Table1.DeliveryDate = DateAdd("hh",2,[t2].[DeliveryDate]);
SELECT DateAdd("h",2,Table1.DeliveryDate) AS NewDateTime
FROM Table1;
SELECT DateAdd("hh",2,Table1.DeliveryDate) AS NewDateTime
FROM Table1;
SELECT (Table1.DeliveryDate + 2/24) AS NewDateTime
FROM Table1;
CREATE TABLE testtime (my_date datetime);
INSERT INTo testtime VALUES (GETDATE());
this prints the actual date
select * from testtime
this prints time + 2 hrs
select DATEADD(HOUR, 2, my_date) from testtime