
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we use MySQL function STR_TO_DATE(Column, ‘%input_format’)?
STR_TO_DATE() function will convert a string value into datetime value and it would be according to a specific format string. Both string value and format string must be passed as arguments to the function. Following is the syntax of STR_TO_DATE() function.
STR_TO_DATE(string, format)
Here string is the value of string which needs to be converted to datetime value and format is the specified date format.
The following example will return valid date from given string and according to the specified format.
mysql> Select STR_TO_DATE('20172810', '%Y%d%m'); +-----------------------------------+ | STR_TO_DATE('20172810', '%Y%d%m') | +-----------------------------------+ | 2017-10-28 | +-----------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- In MySQL, how can we use FROM_UNIXTIME() function with format string?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can we use MySQL SUM() function?
- How to use together the date and time format characters in MySQL DATE_FORMAT() function?
- How can I use TIME_FORMAT() function to offload time/date values in MySQL?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How can we use MySQL SUM() function with HAVING clause?
- How can we use MySQL SUM() function to calculate the sum of only dissimilar values of the column?
- Can we use backticks with column value in MySQL?
- In MySQL, how can we display the date in other format specified by the user?
- How can we insert current date automatically in a column of MySQL table?

Advertisements