To convert datetime to a formatted date time character in Oracle, we use TO_CHAR(Column,Format) function.

TO_CHAR (datetime) converts a datetime or interval value of DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, or TIMESTAMP WITH LOCAL TIME ZONE datatype to a value of VARCHAR2 datatype in the format specified by the date format fmt. If you omit fmt, then date is converted to a VARCHAR2 value as follows:

  • DATE values are converted to values in the default date format.
  • TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE values are converted to values in the default timestamp format.
  • TIMESTAMP WITH TIME ZONE values are converted to values in the default timestamp with time zone format.

SELECT  TO_CHAR(A.AUDIT_STAMP, ‘DD-MON-YYYY HH24:MI:SS’) FROM PSAUDIT A

Advertisements