In Sybase ASE you can use DATEADD function to add an interval to the datetime value. In MariaDB you can use TIMESTAMPADD function, but note that the interval unit specifiers can be different:
Sybase ASE:
-- Add 1 day to the current datetime SELECT DATEADD(dd, 1, GETDATE()) # 2017-12-17 10:38:11.343 -- Subtract 1 day from the current datetime SELECT DATEADD(dd, -1, GETDATE()) # 2017-12-15 10:38:11.343
MariaDB:
-- Add 1 day to the current datetime SELECT TIMESTAMPADD(day, 1, NOW(3)); # 2017-12-17 10:38:11.343 -- Subtract 1 day from the current datetime SELECT TIMESTAMPADD(day, -1, NOW(3)); # 2017-12-15 10:38:11.343
You can use SQLines SQL Converter to convert Sybase ASE DATEADD function to TIMESTAMPADD that maps the interval units to the appropriate values in MariaDB:
Conversion examples:
Sybase ASE | MariaDB | |
1 | SELECT DATEADD(mi, 3, GETDATE()) | SELECT TIMESTAMPADD(minute, 3, NOW()); |
2 | SELECT DATEADD(hh, 3, GETDATE()) | SELECT TIMESTAMPADD(hour, 3, NOW()); |
3 | SELECT DATEADD(mm, 1, GETDATE()) | SELECT TIMESTAMPADD(month, 3, NOW()); |
For more information, see: