Updated on 2024-07-19 GMT+08:00

INTERVAL

In MySQL, the interval expression format is INTERVAL N, which is not supported by GaussDB(DWS) and needs to be converted to INTERVAL'N'.

Input

1
2
3
4
5
6
SELECT CURRENT_TIME() - INTERVAL 4 DAY;
SELECT NOW() - INTERVAL 5 HOUR;
SELECT CURRENT_TIME() - INTERVAL '4' DAY;
SELECT NOW() - INTERVAL '5' HOUR;
SELECT CURRENT_TIME() - INTERVAL "4" DAY;
SELECT NOW() - INTERVAL "5" HOUR;

Output

1
2
3
4
5
6
SELECT  (CURRENT_TIME () - INTERVAL '4' DAY);
SELECT  (NOW () - INTERVAL '5' HOUR);
SELECT  (CURRENT_TIME () - INTERVAL '4' DAY);
SELECT  (NOW () - INTERVAL '5' HOUR);
SELECT  (CURRENT_TIME () - INTERVAL '4' DAY);
SELECT  (NOW () - INTERVAL '5' HOUR);