devxlogo

Finding the Difference Between 2 Dates in MySQL

Finding the Difference Between 2 Dates in MySQL

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  |+-------------------+

devx-admin

Share the Post: