CONVERT - String to Datetime - Sybase ASE to Oracle Migration

In Sybase Adaptive Server Enterprise (ASE) 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 Sybase ASE CONVERT and Oracle formats are different.

Sybase ASE:

  -- Convert string to datetime
  SELECT CONVERT(DATETIME, '12/28/2022 11:13:31', 110); 
  # 2022-12-28 11:13:31 AM

Oracle:

  -- Convert string to datetime
  SELECT TO_TIMESTAMP('12/28/2022 11:13:31', 'MM/DD/YYYY HH24:MI:SS'); 
  # 28-DEC-22 11.13.31.000000000 AM

Mapping Sybase ASE Datetime Style to Oracle Format

When you convert CONVERT function to TO_TIMESTAMP you have to map the Sybase ASE style to the appropriate format string in Oracle:

Sybase ASE 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

Conversion examples:

Sybase ASE Oracle
CONVERT(DATETIME, '12/28/2022', 101) TO_TIMESTAMP('12/28/2022', 'MM/DD/YYYY')
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 Sybase ASE to Oracle Migration.