Ran into similar problem recently, just wanted to share my solution. The idea behind my solution is to take a date, far back in time, I’ve taken 1/1/2015 (D/M/Y format) ( actually “any” other reasonable date can be used with my function ) and simply calculate how many days passed since that date using a simple function:

```
//==========================================================
//CODE CALCULATES DAYS BETWEEN NOW AND 1ST JAN 2015
int daysSince2015 (int days, int months, int years)
{
int daysPerMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
int daysPassed = 0;
int startDays = 1;
int startMonth = 1;
int startYears = 2015;
//KEEP SCROLLIN' TILL THE REQUIRED YEAR IS REACHED
for (startYears = 2015; startYears != years; startYears ++)
{
for (int n = 0; n < 12; n++)
{
//ONE MONTH AT A TIME
daysPassed += daysPerMonth [n];
//ADD LEAP DAY IF REQUIRED
if ((n == 1) && ((startYears % 4) == 0))
{
daysPassed += 1;
}
}
}
//SCROLL MONTHS IF THE MONTHS IS NOT JANUARRY
if (startMonth != months)
{
//SCROLL MONTH, USE startMonth AS A CURSOR TO daysPerMonth ARRAY
//KEEP IN MIND THAT 1ST ELEMENT OF daysPerMonth ARRAY IS AT daysPerMonth[0]
for (startMonth = 1; startMonth != months; startMonth ++)
{
//ONE MONTH AT A TIME
daysPassed += daysPerMonth [startMonth - 1];
//ADD A DAY IF IT'S FEBRUARY OF A LEAP YEAR
if ((startMonth == 2) && ((startYears % 4) == 0))
{
daysPassed += 1;
}
}
}
//SINCE WE ARE ON THE SAME MONTH AND YEAR, JUST CALCULATE DAY DIFFERENCE
daysPassed += days - startDays;
//PRINT THE RESULT
Serial.print("DAYS PASSEDS: ");
Serial.println(daysPassed);
//RETURN THE RESULT
return daysPassed;
}
//=============================================================
```

Calculate this function for both dates of interest, the result of subtraction will represent the days difference between dates. The function was tested, and the results are proven using : Calculate Duration Between Two Dates – Results