Skip to content
Advertisement

SQL – Inster into with now() minus one day

I want change this request. Actualy this request insert into always 2021-11-11 at 10:50:00

INSERT INTO my_table(name, start_date) VALUES('test', '2021-11-11 10:50:00);

I use a script.sql for my H2 database (continous delivery). I want change my request to Now() minus one day at 10:50:00.

Advertisement

Answer

Subtract a day from the current date, then add the time.

INSERT INTO my_table (name, start_date) VALUES 
('test', DATEADD(DAY, -1, CURRENT_DATE) + TIME '10:50:00');
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement