dcsimg
 

Submitted by: M S Sridhar(sridhar.ms@gmail.com)

Monday Apr 9th 2018 by M S Sridhar

Language: SQL, Expertise: Intermediate - See which MySQL function computes the difference between two dates and returns a positive result if the first date is greater than the second date.

MySQL provides a function DATEDIFF that takes two arguments, first date and the second date. The function computes the difference between them and returns a positive result if the first date is greater than the second date.

Command: SELECT DATEDIFF('2018-03-20','2018-03-10') AS 'DATE DIFFERENCE';

Expected output:

+-------------------+
|DATE DIFFERENCE    |
+-------------------+
|               10  |
+-------------------+
Home
Mobile Site | Full Site