
- 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
What MySQL returns on passing an invalid string as an argument to STR_TO_DATE() function?
If we pass an invalid string as an argument to STR_TO_DATE() function then MySQL will return NULL as output along with a warning. Following is an example to understand the same −
mysql> Select STR_TO_DATE('20173210', '%Y%d%m'); +-----------------------------------+ | STR_TO_DATE('20173210', '%Y%d%m') | +-----------------------------------+ | NULL | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec)
In the query above the string value is invalid because of wrong (32) day value. Hence it returns NULL values and a warning which is given below.
mysql> Show warnings\G *************************** 1. row *************************** Level: Warning Code: 1411 Message: Incorrect datetime value: '20173210' for function str_to_date 1 row in set (0.00 sec)
- Related Articles
- What MySQL returns if we include time components along with date component as an argument to DATEDIFF() function?
- What MySQL returns if we include date components along with time component as an argument to TIMEDIFF() function?
- What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?
- What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?
- What MySQL ELT() function returns if we the index number, provided as an argument, is less than 1?
- When MySQL SUBSTRING_INDEX() function returns the same string, provided in the argument, as output?
- What happens if we provide NULL as an argument to MySQL CHAR() function?
- What is the range of date time value that we can pass as an argument to MySQL UNIX_TIMESTAMP function?
- What MySQL returns if specified format string is not as per accordance with the date string passed as arguments to STR_TO_DATE() function?
- What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?
- How to pass an entire structure as an argument to function in C?
- What MySQL CONCAT() function returns by passing the numeric arguments?
- What MySQL returns if the search string is not in the list of strings provided as argument in FIELD() function?
- What MySQL returns if we use UNIX_TIMESTAMP() function with no argument?
- What MySQL returns if the argument of QUOTE() function is NULL?

Advertisements