
- 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
In MYSQL, how can we store a date where the day, month or both month & day are zero?
day are zero?
To store such kind of dates where the day, month or both month & day are zero we must have to set mode of sql to allow_invalid_dates mode.
mysql> set sql_mode = 'allow_invalid_dates'; Query OK, 0 rows affected (0.00 sec) mysql> insert into check_date(OrderDate) values('2017-00-00'); Query OK, 1 row affected (0.06 sec) mysql> select * from check_date; +-------------+ | OrderDate | +-------------+ | 2017-00-00 | +-------------+ 1 row in set (0.00 sec)
Above query will insert the date in which both month & day values are zero.
mysql> insert into check_date(Orderdate) values ('2017-00-05'); Query OK, 1 row affected (0.07 sec) mysql> select * from check_date; +------------+ | Orderdate | +------------+ | 2017-00-00 | | 2017-00-05 | +------------+ 2 rows in set (0.00 sec)
Above query will insert the date in which month value is zero.
mysql> insert into check_date(Orderdate) values ('2017-05-00'); Query OK, 1 row affected (0.02 sec) mysql> select * from check_date; +------------+ | Orderdate | +------------+ | 2017-00-00 | | 2017-00-05 | | 2017-05-00 | +------------+ 3 rows in set (0.00 sec)
Above query will insert the date on which day value is zero.
- Related Articles
- How can we fetch month and day from a given date in MySQL?
- Create date from day, month, year fields in MySQL?
- How to display first day and last day of the month from date records in MySQL?
- Format MySQL date and convert to year-month-day
- Compare only day and month with date field in MySQL?
- Finding day of week from date (day, month, year) in JavaScript
- How to Convert Numbers to Year/Month/Day or Date in Excel?
- How to convert year, month, and day of the month into a complete date in R?
- Fetch date records comparing with the current date’s day and month in MySQL
- How to get a Date from year, month and day in Java?
- How can we provide a date with only year (zero months & zero days) value in MySQL?
- How can we extract the Year and Month from a date in MySQL?
- In MySQL, how we can compute date by providing the year, week number and day of the week?\nday of the week?
- How to get the first day of next month in MySQL?
- How to get last day of the current month in MySQL?

Advertisements