Convert number to date sql oracle

I am trying to convert number ( yyyymmdd) to date ( mm/dd/yyyy)

for instance

20150302 ====> 03/02/2015
+4
source share
3 answers

You can try the following:

select to_date(20150302,'yyyymmdd') from dual;

or

select to_char(to_date(20150302,'yyyymmdd'),'mm/dd/yyyy') from dual;
+7
source

You can use the TO_DATE function to convert to . Try the following: NUMBERDATE

SELECT TO_DATE(20150302, 'YYYYMMDD') FROM DUAL
0
source

TO_DATE char CHAR, VARCHAR2, NCHAR NVARCHAR2 DATE.

, to_date. , .

SELECT TO_DATE('20150302', 'YYYYMMDD')  FROM dual;

Remember that DATE is not formatted, what you see is for display. If you want to display the date in the desired format, use TO_CHAR along with the desired format model.

SELECT TO_CHAR(TO_DATE('20150302', 'YYYYMMDD'), 'mm/dd/yyyy') FROM dual;

Learn more about TO_DATE .

0
source

All Articles