Skip to content

DATEDIFF

  • expr1: The initial date or datetime value from which the difference is calculated. It can be input as a date string or an existing date/datetime column in a table.
  • expr2: The subsequent date or datetime value to which the difference is calculated. Like expr1, this can also be input as a date string or an existing date/datetime column in a table.
SELECT DATEDIFF('2020-07-20','2020-07-01') AS Days;
19

The DATEDIFF() function in MySQL calculates the difference in days between two date values. In this example, the function calculates the difference between ‘2020-07-20’ and ‘2020-07-01’ which results in 19 days.