Frage

my question may duplicated, I researched but I couldn't find out the answer I need.

My question is how can I re-formatting data from mysql select query.

comlum_01 is Char and data like 07/25/2013 or 7/25/2013.

I want to change query data to '20130725'.

Below is the sql sentence I want to make, change and put data in comlum new_comlum

Select A.comlum_01, reformat(A.comlum_01) as new_comlum from table_01 A;

this one looks like similar but...

reformatting a date

Thank you very much for your help.

War es hilfreich?

Lösung

SELECT A.comlum_01,  DATE_FORMAT(str_to_date(A.comlum_01, '%m/%d/%Y'), '%Y%m%d') AS New_comlum 
FROM table_01 A;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top