In Sybase ASE you can use DATEDIFF function to get the difference between two datetime values in the specified interval units (days, hours, minutes etc.). In MariaDB you can use TIMESTAMPDIFF function, but note that the interval unit specifiers can be different:
Sybase ASE:
-- Get difference in days between two datetimes SELECT DATEDIFF(dd, '2017-12-16', '2017-12-31') # 15
MariaDB:
-- Get difference in days between two datetimes SELECT TIMESTAMPDIFF(day, '2017-12-16', '2017-12-31'); # 15
You can use SQLines SQL Converter to convert Sybase ASE DATEDIFF function to TIMESTAMPDIFF that maps the interval units to the appropriate values in MariaDB:
Conversion examples:
Sybase ASE | MariaDB | |
1 | SELECT DATEDIFF(mi, GETDATE(), '2017-12-31') | SELECT TIMESTAMPDIFF(minute, NOW(), '2017-12-31'); |
2 | SELECT DATEDIFF(hh, GETDATE(), '2017-12-31') | SELECT TIMESTAMPDIFF(hour, NOW(), '2017-12-31'); |
3 | SELECT DATEDIFF(mm, GETDATE(), '2017-12-31') | SELECT TIMESTAMPDIFF(month, NOW(), '2017-12-31'); |
For more information, see: