Computes the number of days between two serial Julian dates <span align="right" style="background-color:99FF99"><strong>Open Office: DATEDIFF</strong></span>

View versions (1)

Interface

#include <codecogs/units/date/datediff.h>

using namespace Units::Date;

Returns the number of days between two serial Julian dates. Aside from adding clarity to your code, we can see few reasons for anyone to use this function directly, we only provide it for completeness against Excel. For something more involved see dateDiff360. We recommend that you make the necessary subtraction yourself, the entire function is only:

inline int dateDiff(int nDateStart, int nDateEnd)
{
  return nDateStart - nDateEnd;
}

Example:

#include <stdio.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;

void main()
{
printf("\n Difference=%d days", dateDiff(date("12-8-2004"), date("20-8-2004")));  // Difference=8 days
}

Parameters

startDate
and...
endDate
are serial Julian dates (see date ). The return value is signed, so if StartDate occurs before endDate then a negative answer will be returned. See date , for details on creating these numbers.
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

startDate
endDate
Result