
- 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
Why we cannot use MySQL DATE data type along with time value?
The default format for MySQL DATE data type is “YYYY-MM-DD” and in this format, there is no possibility to store the time value. Hence, we can say that we cannot use DATE data type along with time value.
As we can see in the following example MySQL returns only date value even on using time along with the date.
mysql> select DATE("2017-09-25 09:34:21"); +-----------------------------------+ | DATE("2017-09-25 09:34:21") | +-----------------------------------+ | 2017-09-25 | +-----------------------------------+ 1 row in set (0.04 sec)
However, in DATETIME and TIMESTAMP date data types we can use the time to date.
- Related Articles
- How MySQL evaluates if I store date along with time value in a column having DATE data type?
- Changing data type from date to date/time in MySQL?
- Why in MySQL, we cannot use arithmetic operators like ‘=’, ‘
- In MySQL, when VARCHAR data type will use 1-byte and when 2-bytes prefix length along with data?length along with data?
- How can we use MySQL REVERSE() function on column’s data along with WHERE clause?
- Can we use IFNULL along with MySQL ORDER BY?
- 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?
- Increment date/time value by second with MySQL query?
- How to use TIME type in MySQL?
- Can we use backticks with column value in MySQL?
- In what cases, we cannot use MySQL TRIM() function?
- Data Types we cannot use to create array in C
- How MySQL use YEAR data type to store year value in a table?
- What should one use CHAR data type or VARCHAR data type in MySQL?

Advertisements