Micah
Micah

Reputation: 4560

mysql, reformat data inside select sentence

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.

Upvotes: 1

Views: 99

Answers (1)

Akhil
Akhil

Reputation: 2602

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;

Upvotes: 2

Related Questions