String to Date format by str_to_date()We have to use particular format for date & time data before storing to mysql date field. So if a user entered data is to be stored in a table then we have to change the format by using different string functions and convert them to acceptable date format. You can read this tutorial to know how the string functions are used to format the user entered data to mysql table.
By using the function str_to_date() we can convert the string data to mysql required format of date field. This function requires the string data and the format in which it is available.
Now let us try with some examples of this str_to_date function and its outputs.
Output of above query is 2008-12-15
Same way here are some examples and the outputs of str_to_date function for your understanding
Try with some illegal date
Learn how str_to_date is used to format date value stored as text in Varchar field of MySQL table
This article is written by plus2net.com team.
▼ More on Date & Time functions in SQL