how can i get the number of days between two dates?

• 02-29-2008
acohrockz21
how can i get the number of days between two dates?
hi..im new i just want to ask..some few questions about my homework coz i dont know what code i am going to use..
i can't fully understand the codes that are in the FAQ..

for example..
i entered a date of march 21 2007, and I entered a date of april 3, 2007
i want to get the difference of the days of the two dates..

what code am i going to use and how can i apply it?
sorry for my bad english >_<

sorry for the inconvinence
• 02-29-2008
matsp
If you can get the date into a "time_t" type, you can use difftime() which is a standard function in the C runtime library. difftime gives you the number of seconds between two time values, and time in itself is "date and time" combined.

And as a help, 24 * 60 * 60 -> 86400, so the days is "seconds/86400".

--
Mats
• 02-29-2008
BobS0327
Possibly calculate the Julian day number for beginning date and ending date. Then subtract the beginning Julaian day number from the ending Julian day number.

A formula for calculating Julian day numbers can be found at this Julian day wiki
• 02-29-2008
Dave_Sinkula