I have table name bill_date and this is my table row, the field type of create_date is character varying
id | create_date
1 | 20080108
2 | 20080116
I want to convert create_date to Date but when I used this QUERY
SELECT to_date(create_date, 'YYYYddmm'),* FROM bill_date
I got wrong result
2008-08-01
2009-04-03
there something wrong in field type? any help. thanks
2008-01-08? Can I suggest you leave it in the format given to you byto_date, as this is ISO format?select '20080108'::date2008-08-01for the formatYYYYddmmabsolutely correct for the input value20080108. 2008 = YYYY, 01 = dd, 08 = mm. If you want the input value to be parsed differently you need to use a different format mask, e.g.yyyymmdd