FUNCTION
dateDiff
Computes the number of days between two serial Julian dates <span align="right" style="background-color:99FF99"><strong>Open Office: DATEDIFF</strong></span>
You're viewing an older version of this page (#192). View the current version.
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
Interactive Calculator
startDate
endDate
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.