excel formula to calculate the number of years between two dates code example
Example 1: Google Sheets How to Count the Days Between Two Dates
# Basic syntax:
=DAYS("end_date", "start_date")
# Example:
=DAYS("01/01/2019","01/01/2018")
# Note, use =NETWORKDAYS for business days
Example 2: How to calculate the difference between two dates
$datetime1 = new DateTime('2020-10-11 16:52:52');
$datetime2 = new DateTime('2020-10-13 16:52:52');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%a days');