how can I calculate the number of days between two dates?

I found some programs on the internet that do it but none gave me the formula on how it works :(.

if it makes it any simpler, I'm using php (maybe with build in functions)

thx

--Maes

Printable View

- 07-12-2004maesdays between dates formula
how can I calculate the number of days between two dates?

I found some programs on the internet that do it but none gave me the formula on how it works :(.

if it makes it any simpler, I'm using php (maybe with build in functions)

thx

--Maes - 07-12-2004DavidP
...that's just simple addition and subtraction...unless there is something i dont understand here...

Days between Jan 5th and April 7th:

NumDaysJan() + NumDaysFeb() + NumDaysMarch() + 7 - 5

P.S. those are not real functions...that's pseudocode... - 07-12-2004Jeremy G
Find number of elapsed years

Multiply the number of days in a year times the number of elapsed years

add 1 day to that number per leap year in elapsed years

find number of elapsed months (not included in elapsed years)

add all the days of those elapsed months

find the number of elapsed days in the month (not included in elapsed months)

violla. - 07-12-2004maes
Oh man I'm o embarresed :D

I read something on the internet about julian days.

actualy found a fromula that was about a page in length and stuff like that so I thought there would be a catch somwhere.

I kept thinking with hunderd of years between the dates that I didn't see it was that simple :D

thx DavidP ;) & db_goten - 07-12-2004Zach L.
No... Dates are terribly hideous to work with. There is an example in Numerical Recipes that gets the Julian Day Number given a calendar date.

http://lib-www.lanl.gov/numerical/bookcpdf.html

It is section 1.1, starting on the 7th page. The function is 'julday'