I am working with the HR SQL database (ORACLE), and I would like to know how to change the date format
Current format
- 06/17/03
Future or expected format
- June 17, 2003
I am working with the HR SQL database (ORACLE), and I would like to know how to change the date format
If you want to retrieve the results stored in BDD with this format, in the selects you use to obtain the dates you can use this formatting. Surely there is some more efficient way, but hey, I leave it here:
select to_char(col_fecha, 'DD') || ' de ' ||to_char(col_fecha, 'MONTH') || ' del año ' || to_char(col_fecha, 'YYYY')
from tabla;
If the field is nullable you will need to enter a CASE WHEN
to control those specific cases.
Complex cases are not necessary, TO_CHAR
can handle the format. You just need to pass the code of value NLS_DATE_LANGUAGE
adequate. The accepted solution may not be the correct result (for the value of the month) if the NLS_DATE_LANGUAGE
of the session is other than SPANISH
SELECT TO_CHAR(CAMPO_FECHA, 'DD "de" Month "del año" YYYY', 'NLS_DATE_LANGUAGE=SPANISH') FROM tabla;
Exit:
08 de Marzo del año 2018