Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Interval to date in HSQLDB

Tags:

date

hsqldb

How can i add for example 1 month to a date (already in the db) in a HSQL database.

In MySQL it would be :

UPDATE TABLE_CA SET DATE_A = DATE_ADD(DATE_A, INTERVAL 1 MONTH) WHERE id = 45

This function is supposed to work in HSQL but i got the following error :

Object not found : DATE_ADD

I'm using hsqldb 2.2.6 and cannot find the way to do this. I also tried DATEADD() function with the same result.

like image 739
caRameL Avatar asked Sep 25 '13 15:09

caRameL


1 Answers

No need to call a function, HSQLDB supports SQL standard interval literals.

UPDATE TABLE_CA 
    SET DATE_A = DATE_A + INTERVAL '1' MONTH
WHERE id = 45;
like image 88
a_horse_with_no_name Avatar answered Nov 09 '22 08:11

a_horse_with_no_name