How to convert VARCHAR to TIMESTAMP in MySQL?

I have a date column in varchar format. How can i change it to date format in mysql workbench?

  • Actually in the database i have three columns: birthdate, birthmonth and birthyear. I am using this query to get a birthday column-- SELECT * FROM ( SELECT customer no, Concat(birthYear,'-',birthMonth,'-',birthDay) AS dob from 'Tablename' group by customer no )A; now the date i am getting is in varchar format and i want to convert it in date format- yyyy-mm-dd. Please keep in mind that that if date or months are in single digit then there is no '0' before them. So if the date is 5th june 2012 then it is concatenated as 2012-6-5 but i want my final date as 2012-06-05. Please help

  • Answer:

    Use http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date Example: SELECT STR_TO_DATE('01,5,2013','%d,%m,%Y'); returns 2013-05-01

Franck Dernoncourt at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.