# days between dates formula

This is a discussion on days between dates formula within the A Brief History of Cprogramming.com forums, part of the Community Boards category; how can I calculate the number of days between two dates? I found some programs on the internet that do ...

1. ## days 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

2. ...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...

3. 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.

4. Oh man I'm o embarresed