

- 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
What MySQL returns if we include time components along with date component as an argument to DATEDIFF() function?
MySQL DATEDIFF() function also works with date and time values but it ignores the time value. Hence even if we include the time value in DATEDIFF() function MySQL will return the difference, in days, between dates by ignoring the time values.
mysql> Select DATEDIFF('2018-10-22 04:05:36','2017-10-22 03:05:45'); +-------------------------------------------------------+ | DATEDIFF('2018-10-22 04:05:36','2017-10-22 03:05:45') | +-------------------------------------------------------+ | 365 | +-------------------------------------------------------+ 1 row in set (0.00 sec) mysql> Select DATEDIFF('2017-10-22 04:05:36','2017-10-22 03:05:45'); +-------------------------------------------------------+ | DATEDIFF('2017-10-22 04:05:36','2017-10-22 03:05:45') | +-------------------------------------------------------+ | 0 | +-------------------------------------------------------+ 1 row in set (0.00 sec)
The queries above shows how DATEDIFF() function ignores the time value while calculating the difference between dates.
- Related Questions & Answers
- What MySQL returns if we include date components along with time component as an argument to TIMEDIFF() function?
- What MySQL returns if we use UNIX_TIMESTAMP() function with no argument?
- What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?
- What happens if we provide NULL as an argument to MySQL CHAR() function?
- What MySQL ELT() function returns if we the index number, provided as an argument, is less than 1?
- What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?
- What MySQL returns on passing an invalid string as an argument to STR_TO_DATE() function?
- What is the range of date time value that we can pass as an argument to MySQL UNIX_TIMESTAMP function?
- What MySQL returns if the argument of QUOTE() function is NULL?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- What MySQL returns if the list of strings, provided as argument in FIELD() function, are NULL?
- What MySQL EXPORT_SET() function returns if any of the argument is NULL?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What MySQL COALESCE() function returns if it has a blank, but not NULL, as the first argument?
- What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?
Advertisements