I have a table in which dates are stored in string format and I want to change its format from yyyyMMdd to yyyy-MM-dd and store it back in string format only. I am using Aginity workbench.
Referred link - convert MM/DD/YYYY to YYYYMMDD in redshift , and its solution is not working properly.
First,I tried it in simple query, which is working fine :
select to_char(to_date('20150614', 'yyyyMMdd'),'yyyy-MM-dd') as SDate;
Output :
sdate
2015-06-14
However, when I am trying in my actual query(in JOIN), Its giving me some weird value :
select to_char(to_date(s.date, 'yyyy-MM-dd'),'yyyy-MM-dd') as SDate, s.date, e.code, s.id
from student as s join event as e on e.code =
> s.id
order by SDate asc
limit 1
Output :
sdate date code id
139496-03-09 20150614 art art
I am not sure, if this is because of query on bulk data or using JOIN or any other issue.
Can someone please help me on this or is there any other solution, I am new to RedShift. Any help would appreciated !!!