IntermediateDate & Time Functions
TO_CHAR: format dates as strings
The query
SQL
SELECT
hire_date,
TO_CHAR(hire_date, 'DD Month YYYY') AS formatted,
TO_CHAR(hire_date, 'Mon DD, YYYY') AS short_format,
TO_CHAR(hire_date, 'YYYY-MM-DD') AS iso_format,
TO_CHAR(hire_date, 'Day, DD/MM/YYYY') AS day_format,
TO_CHAR(NOW(), 'HH24:MI:SS') AS time_only
FROM employees
LIMIT 5;Note
“TO_CHAR formats: YYYY (year), MM (month num), Mon (abbr), Month (full), DD, HH24, MI, SS.