Reputation: 31
When running
select processing_date from table;
i got this result "04-30-2020 20.12.49.978711" what i want to change the format of the result to "30-APR-20"
is there a way i can do that ?
i tried select to_date(processing_date,'mm-dd-yyyy') from table;
but it gives me errors
any help ?
Upvotes: 1
Views: 3188
Reputation: 1269493
You want to_char()
:
select to_char(processing_date, 'MM-DD-YYYY')
Dates are stored as an internal format, which you cannot change. If you want the date formatted in a particular way, then one solution is to convert to a string with the format you want.
EDIT:
The date appears to be a string. You can convert it to a date using:
select to_date(substr(processing_date, 1, 10), 'MM-DD-YYYY')
You can then either use as-is or use to_date()
to get the format you really want.
Upvotes: 1