How to format a date in Oracle PL/SQL

Date fields in Oracle hold the time, but by default, the time is not displayed.

Below is a sample of how to format the date with time:

<pre>
   TO_CHAR(CREATION_DATE, 'YYYY-MM-DD HH24:MI:SS') as CREATION_DATE
</pre>

Example:

<pre>
select Creation_Date, TO_CHAR(CREATION_DATE, 'YYYY-MM-DD HH24:MI:SS') as CREATION_DATE_Fmt 
from PO.PO_HEADERS_ALL
where Creation_Date is not null 
order by Creation_Date desc 
</pre>

Notice how the time does not appear by default in the first field displayed:

Uncategorized  

Leave a Reply