- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How is it possible to store date such as February 30 in a MySQL date column?
Suppose we want to store the date such as February 30 in a MySQL table then we must have to first set ALLOW_INVALID_DATES mode enabled.
For example, I am trying to add, without enabling ALLOW_INVALID_DATES mode, such kind of date in a table then MySQL will give an error as follows −
mysql> Insert into date_testing(date) values('2017-02-30'); ERROR 1292 (22007): Incorrect date value: '2017-02-30' for column 'Date' at row1
Now we need to enable ALLOW_INVALID_DATES mode enabled as follows −
mysql> SET sql_mode = 'ALLOW_INVALID_DATES'; Query OK, 0 rows affected (0.00 sec) mysql> Insert into date_testing(date) values('2017-02-30'); Query OK, 1 row affected (0.14 sec) mysql> select * from date_testing; +------------+ | Date | +------------+ | 2017-02-30 | +------------+ 1 row in set (0.00 sec)
Above MySQL query will allow us to insert such kind of invalid dates in a column.
- Related Articles
- How can I store ‘0000-00-00’ as a date in MySQL?
- Is it okay to store double and date in VARCHAR with MySQL?
- How MySQL evaluates if I store date along with time value in a column having DATE data type?
- MySQL Order By date column and integer column, but specify ordering rules of integer column? Is it possible?
- How to update a MySQL date type column?
- Add 30 days to date in a MySQL table with arrival date records
- How to set default date time as system date time in MySQL?
- How to compare the first date and the last date from a MySQL column with date records?
- How to cast DATETIME as a DATE in MySQL?
- What is the easiest way to store date in MySQL database?
- MySQL query to delete a DATE older than 30 days from another date?
- How to store and retrieve a date into MySQL database using Python?
- MySQL date column auto fill with current date?
- MySQL CAST as DATE?
- How to convert a MySQL date to JavaScript date?

Advertisements