Click to See Complete Forum and Search --> : Calculating Months using a COleDateTimeSpan object


Troy T
May 3rd, 1999, 03:32 PM
Hello, I need to calculate Months using a COleDateTimeSpan object. With this object you can get days, hours, minutes, and seconds. I need to calculate Months. I have already added code that will calculate years, and weeks (which are both easy, just nDays * 365 (years) or nDays * 7 (weeks) but Months are more difficult).

Can anyone help me with a calculation? I was thinking about this, and tried it, but it didn't work properly:


double dYears = nTotalDays / 365.25;
int nMonths = (int)nYears * 12;




Thanks for any help that you can offer! :)

- Troy

sally
May 3rd, 1999, 07:22 PM
you can't do it like that, since months have different lengths
BTW, so do years

Sally

Sally
May 3rd, 1999, 07:22 PM
you can't do it like that, since months have different lengths
BTW, so do years

Sally

Troy T
May 3rd, 1999, 07:26 PM
Yes, I realize that this piece of code doesn't work, but what I need is an algorithm that will work.

Do you have any suggestions?

- Troy