Calculating Months using a COleDateTimeSpan object
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
Re: Calculating Months using a COleDateTimeSpan object
you can't do it like that, since months have different lengths
BTW, so do years
Sally
Re: Calculating Months using a COleDateTimeSpan object
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