
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 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 Questions & Answers
- How MySQL behaves if I use INTERVAL keyword with an invalid date?
- How can I use INTERVAL keyword with MySQL NOW() and CURDATE() functions?
- 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?
- What MySQL returns if I use enclosed set of unit values with INTERVAL keyword?
- How can I use MySQL INTERVAL() function with a column of a table?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can we use MySQL INSTR() function with WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE 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 MySQL SUM() function with HAVING clause?
- How can we use MySQL SUM() function?
Advertisements