TO_DATE
converts a string to a DATE
. A DATE
is stored in a packed binary format that is not human readable. An Oracle DATE
does not have a format. So when you ask a program to display a date, it has to then convert the DATE
to a string. If you don't explicitly specify the format by doing an explicit TO_CHAR
, a tool like SQL*Plus will convert the date to a string using the session's NLS_DATE_FORMAT
. Other applications may choose different ways to convert a date to a string-- using the client's regional settings, for example, or by allowing the user to configure the format.
If you want to return a string in a particular format that represents a DATE
, you'd need to use an explicit TO_CHAR
. Something like
SELECT to_char( some_date_column, 'dd/mm/yyyy hh:mi:ss AM' )
FROM some_table
In the specific case you posted, since you have the string in your hand as a string, you'd simply want to select it from dual rather than doing a TO_DATE
to convert it to a date and then a TO_CHAR
to convert it back to a string. I'm assuming, though, that you have an actual DATE
in the actual table that you are trying to select from.