In SQL Server you can use CONVERT function to convert a string expression in the specified format (style) to a datetime data type (DATE, DATETIME etc.). In Oracle you can to use TO_TIMESTAMP function.
Note that SQL Server CONVERT and Oracle formats are different.
SQL Server:
-- Convert string to datetime SELECT CONVERT(DATETIME, '12/28/2022 11:13:31', 110); # 2022-12-28 11:13:31.000
Oracle:
-- Convert string to datetime SELECT TO_TIMESTAMP('12/28/2022 11:13:31', 'MM/DD/YYYY HH24:MI:SS') FROM dual; # 28-DEC-22 11.13.31.000000000 AM
When you convert CONVERT function to TO_TIMESTAMP you have to map the SQL Server style to the appropriate format string in Oracle:
SQL Server Style | Oracle Format String | Output Example | ||
101 | US | 'MM/DD/YYYY' | 12/28/2022 | |
110 | US | 'MM/DD/YYYY HH24:MI:SS' | 12/28/2022 11:13:31 | |
112 | ISO | YYYYMMDD | 'YYYYMMDD' | '20230119' |
Conversion examples:
SQL Server | Oracle |
CONVERT(DATETIME, '12/28/2022', 101) | TO_TIMESTAMP('12/28/2022', 'MM/DD/YYYY') |
CONVERT(DATETIME, '20230119', 112) | TO_TIMESTAMP('20230119', 'YYYYMMDD') |
CONVERT(DATETIME, '12/28/2022 11:13:31', 110) | TO_TIMESTAMP('12/28/2022 11:13:31', 'MM/DD/YYYY HH24:MI:SS') |
For more information, see SQL Server to Oracle Migration.