in reply to Comparing two dates and finding out number of days
How about transforming both dates in days and finding the difference? Yes, you will need to account for leap years. How about finding the number of days till the end of the month of the first date, then the rest of the year, then add years until the second date, then add (days in the) months until the month number in the second date, then the few days left? Yes, you will also need to account for leap years too (multiple of 4, not of 100, but also multiple of 400). Sounds like an array there index i holds the number of days in that month (then you do the trick with the leap year verification).
Again, since I suspect this is homework, I will stop here and not post any code. This should help plenty I think.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing two dates and finding out number of days
by Ashes.cfg (Initiate) on Nov 15, 2007 at 16:56 UTC | |
by agianni (Hermit) on Nov 15, 2007 at 18:07 UTC | |
by blazar (Canon) on Nov 16, 2007 at 11:16 UTC |