TO_DATE()

Description of to_date.eps follows

Syntax:

  • TO_DATE(char [ DEFAULT return_value ON CONVERSION ERROR ] Char: the date string that is being converted The optional DEFAULT return_value ON CONVERSION ERROR clause allows you to specify the value this function returns if an error occurs while converting char to DATE
    [, fmt [, ‘nlsparam’ ] ])
  • TO_DATE converts char to a value of DATE data type
  • For char, you can specify any expression that evaluates to a character string of CHARVARCHAR2NCHAR, or NVARCHAR2 data type
  • fmt is a datetime model format specifying the format of char.
  • nlsparam' argument specifies the language of the text string that is being converted to a date. This argument can have this form: for example, ‘NLS_DATE_LANGUAGE = language’

The example below converts a string to date data type.

SELECT TO_DATE('November 9, 2023',
'MONTH DD, YYYY HH:MI:SS',
'NLS_DATE_LANGUAGE = American')
FROM DUAL;


Example 2

SELECT TO_DATE('December 16, 2022, 12:24:45 PM',
'MONTH DD, YYYY HH:MI:SS PM',
'NLS_DATE_LANGUAGE = AMERICAN') AS TODAYS_DATE
FROM DUAL;

–YY= 2000-2099
— RR= 1950-2049

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top