In Sybase ASE you can use DATEPART function to extract the integer part of the specified unit (a date part such as year, month, day etc.) from a datetime value.
In MariaDB there is no single function with the same functionality, and you have to use YEAR(), MONTH(), DAY() and other functions to extract the required datetime units (date parts).
Sybase ASE:
-- Get the name of week day SELECT DATEPART(dw, '2017-12-17') # 1
MariaDB:
-- Get the name of week day SELECT DAYOFWEEK('2017-12-17') # 1
You can use SQLines SQL Converter to convert Sybase ASE DATEPART function to MariaDB that maps the units to the appropriate datetime functions in MariaDB:
Sybase ASE | MariaDB | Output Example | ||
yy | year | DATEPART(yy, GETDATE()) | YEAR(NOW()) | 2017 |
quarter | DATEPART(qq, GETDATE()) | QUARTER(NOW()) | 4 | |
mm | month | DATEPART(mm, GETDATE()) | MONTH(NOW()) | 12 |
wk | week | DATEPART(wk, GETDATE()) | WEEK(NOW()) | 51 |
dd | day | DATEPART(dd, GETDATE()) | DAY(NOW()) | 17 |
dy | dayofyear | DATEPART(dy, GETDATE()) | DAYOFYEAR(NOW()) | 351 |
dw | weekday | DATEPART(dw, GETDATE()) | DAYOFWEEK(NOW()) | 1 |
hh | hour | DATEPART(hh, GETDATE()) | HOUR(NOW()) | 19 |
mi | minute | DATEPART(mi, GETDATE()) | MINUTE(NOW()) | 22 |
ss | second | DATEPART(ss, GETDATE()) | SECOND(NOW()) | 8 |
ms | millisecond | DATEPART(ms, GETDATE()) | MICROSECOND(NOW(3))/1000 | 396 |
us | microsecond | DATEPART(us, CURRENT_BIGTIME()) | MICROSECOND(NOW(6)) | 324091 |
For more information, see: