1

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.

Community
  • 1
  • 1
Micah
  • 4,254
  • 8
  • 30
  • 38
  • 1
    [Check this out](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date) – Akhil Jul 26 '13 at 04:57
  • 1
    are you looking for this http://stackoverflow.com/questions/1921574/how-to-convert-datetime-to-a-number-in-mysql ? – Nithesh Narayanan Jul 26 '13 at 04:59

1 Answers1

2
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;
Akhil
  • 2,602
  • 23
  • 36