This calculates the number of days between two dates. I haven't thoroughly tested this function. So, it's your responsibility to test it.

Have fun

Bob

Code:

#include <stdio.h>
unsigned long JulianDaysCalc(int iMonth, int iDay, int iYear)
{
//Calculation of serial Julian date
int iTemp;
int iYearCalc;
int iMonthCalc;
unsigned long ulSerialJulianDate;
iTemp = (14 - iMonth)/12;
iYearCalc = iYear + 4800 - iTemp;
iMonthCalc = iMonth+ (12*iTemp) - 3;
ulSerialJulianDate = iDay + (((153*iMonthCalc) +2)/5) + (365*iYearCalc)
+ (iYearCalc/4) - (iYearCalc/100)+ (iYearCalc/400) - 32045;
return ulSerialJulianDate;
}
int main(void)
{
unsigned long ulJdate1, ulJdate2;
ulJdate1 = JulianDaysCalc(11, 22, 2005);
ulJdate2 = JulianDaysCalc(11, 20, 2005);
printf(" Date diff %ld\n", (ulJdate1 - ulJdate2));
return 0;
}