
- 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
How MySQL behaves when we use INTERVAL of time unit with CURDATE() function?
As we know that CURDATE() only returns the date unit so it would be ambiguous to use INTERVAL of time unit with CURDATE(). MySQL always represents current date with ‘00:00:00’ time hence when we use INTERVAL of time unit with CURDATE() then such kind of time arithmetic would take this time into consideration. Following examples will clarify it −
mysql> Select CURDATE() + INTERVAL 0 hour; +-----------------------------+ | curdate() + Interval 0 hour | +-----------------------------+ | 2017-10-28 00:00:00 | +-----------------------------+ 1 row in set (0.00 sec) mysql> select CURDATE() + INTERVAL 1 hour; +-----------------------------+ | curdate() + Interval 1 hour | +-----------------------------+ | 2017-10-28 01:00:00 | +-----------------------------+ 1 row in set (0.00 sec) mysql> Select CURDATE() + INTERVAL 2 hour; +-----------------------------+ | CURDATE() + INTERVAL 2 hour | +-----------------------------+ | 2017-10-28 02:00:00 | +-----------------------------+ 1 row in set (0.00 sec)
- Related Articles
- How can I use INTERVAL keyword with MySQL NOW() and CURDATE() functions?
- How MySQL behaves if I use INTERVAL keyword with an invalid date?
- How to use compound INTERVAL unit in MySQL?
- How to use CONTAINS() with CURDATE in MySQL?
- How can I use the arithmetic operators (+,-,*,/) with unit values of INTERVAL keyword in MySQL?
- How can I use MySQL INTERVAL() function with a column of a table?
- What MySQL returns if I use enclosed set of unit values with INTERVAL keyword?
- How can we use MySQL SUM() function with HAVING clause?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can we use MySQL SUM() function?

Advertisements