Calculating How Many Days between Two Dates
Date: 10/06/2004 at 13:16:15 From: tiffany Subject: how many days are left until 7/10/2006 I'm trying to figure out how may days it will be before we reach July 10, 2006, and I can't figure out how to go about it other than taking a calendar and counting by hand. Is there a way to calculate it?
Date: 10/07/2004 at 10:49:30 From: Doctor Vogler Subject: Re: how many days are left until 7/10/2006 Hi Tiffany, Thanks for writing to Dr. Math. That's a very good question. I asked myself that same question some time ago, and I came up with the following formula. It's not the only formula, but it *does* work. Here is the idea: I am going to give you a function that takes in three numbers, a date (1 to 31), month (1 to 12), and year (such as 2004), and it will give back an integer. The integer is the exact number of days from a certain fixed date. (In my case, it will be some date about 2000 years ago, but you can change it to another date by adding a fixed number.) Then all you have to do is compute this function for 7/10/2006 and for today, and then subtract! There are several ways of coming up with such a function, depending, for example, on how you record the month, day, and year, and what calendar you are using. I will be using the Gregorian Calendar, which is the one in common use in the west (such as America, where I live). You can find more formulas and information from our FAQ: Calendar; Days of the Week http://mathforum.org/dr.math/faq/faq.calendar.html or by searching our archives for something like calendar date days Now, on to the formula: First of all, since February is an especially short month, it is normally better to consider January and February the 13th and 14th months of the previous year. So first, if the month is 1 or 2, then you add 12 to the month and subtract 1 from the year. Then the day is 365*year + year/4 - year/100 + year/400 + date + (153*month+8)/5 where all of the divisions are rounded DOWN to the nearest integer. Do this for both dates, and subtract. If you have any questions about this or need more help, please write back and show me what you have been able to do, and I will try to offer further suggestions. - Doctor Vogler, The Math Forum http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.