how to convert a string to date in mysql?

后端 未结 5 607
谎友^
谎友^ 2020-11-22 07:26

I have a string column which acts as a date and I want to select it as a date.

Is it possible?

My sample data format

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 07:39

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
    use the above page to refer more Functions in MySQL

    SELECT  STR_TO_DATE(StringColumn, '%d-%b-%y')
    FROM    table
    

    say for example use the below query to get output

    SELECT STR_TO_DATE('23-feb-14', '%d-%b-%y') FROM table
    

    For String format use the below link

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

提交回复
热议问题