Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

MySQL STR_TO_DATE Function

by suresh

MySQL STR_TO_DATE function is a Date Function, which acts as an inverse of DATE_FORMAT function. This MySQL STR_TO_DATE function takes a string as an input and converts the string to Date or DateTime or Time values based on the format given by the user. The basic syntax of the STR_TO_DATE() Function in MySQL is as shown below:

STR_TO_DATE(string_expression, format);

MySQL STR_TO_DATE Example

Here, We used the STR_TO_DATE function to convert the different string formats to Date. For this MySQL query, we are using %d %m and %Y formats.

SELECT STR_TO_DATE('31 12 2019', '%d %m %Y');

SELECT STR_TO_DATE('31,12,2019', '%d,%m,%Y');

SELECT STR_TO_DATE('12,2019,31', '%m,%Y,%d');
MySQL STR_TO_DATE Function 1

This is an another Date Function example of this STR_TO_DATE function.

SELECT STR_TO_DATE('12 Jan, 2019', '%d %b, %Y');

SELECT STR_TO_DATE('2nd Jan, 2019', '%D %b, %Y');

SELECT STR_TO_DATE('2nd January, 2019', '%D %M, %Y');
MySQL STR_TO_DATE Function 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy