In Oracle, the TO_TIMESTAMP function converts a string value to a TIMESTAMP data type value using a specified format.
In MariaDB, you can use the STR_TO_DATE function. Note that the TO_TIMESTAMP and STR_TO_DATE format strings are different.
Oracle:
-- Specify a datetime string literal and its exact format SELECT TO_TIMESTAMP('2026-02-02 11:57:03', 'YYYY-MM-DD HH24:MI:SS') FROM dual; /* 02-FEB-26 11.57.03.000000000 AM */
MariaDB:
-- Specify a datetime string literal and its exact format SELECT STR_TO_DATE('2026-02-02 11:57:03', '%Y-%m-%d %H:%i:%s'); /* 2026-02-02 11:57:03 */
You can use SQLines SQL Converter to convert Oracle TO_TIMESTAMP function to STR_TO_DATE function in MariaDB that maps the format specifiers as follows:
| Oracle TO_TIMESTAMP | MariaDB STR_TO_DATE | |
| YYYY | 4-digit year | %Y |
| SYYYY | 4-digit year with a minus sign for BC dates | %Y |
| YY | 2-digit year | %y |
| RRRR | 2 or 4-digit year, 20th century for 00-49 | %Y |
| RR | 2-digit year, 20th century for 00-49 | %y |
| MON | Abbreviated month (Jan - Dec) | %b |
| MONTH | Month name (January - December) | %M |
| MM | Month (1 - 12) | %m |
| DY | Abbreviated day (Sun - Sat) | %a |
| DD | Day (1 - 31) | %d |
| HH24 | Hour (0 - 23) | %H |
| HH or HH12 | Hour (1 - 12) | %h |
| MI | Minutes (0 - 59) | %i |
| SS | Seconds (0 - 59) | %s |
| FF or FF6 | Microseconds (000000 - 999999) | %f |
Conversion examples:
| Oracle | MariaDB | |
| 1 | TO_TIMESTAMP('02-FEB-2026 11:57:03.123456', 'DD-MON-YYYY HH24:MI:SS:FF') | STR_TO_DATE('02-FEB-2026 11:57:03.123456', '%d-%b-%Y %H:%i:%s.%f') |
For more information, see Oracle to MariaDB Migration.