joan2006
asked on
calculate number of months between two date
I am trying to calculate the number of months between two dates in c#.
I have two dates in a c# string.
At first i was calculating Mat.Abs(DateTime.Parse(txt StartDt.Va lue).Month - DateTime.Parse(txtEndDt.Va lue).Month ))+ 1
Then i realized that i may have values where the years differ eg. 2007 - 2009 the code i have above doesnt account for that.
What would be the best solution/algorithm to get the correct number of months from two dates?
I have two dates in a c# string.
At first i was calculating Mat.Abs(DateTime.Parse(txt
Then i realized that i may have values where the years differ eg. 2007 - 2009 the code i have above doesnt account for that.
What would be the best solution/algorithm to get the correct number of months from two dates?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Add a DLL reference Microsoft.VisualBasic to the application
found in the .Net Tab of the Add Reference dialog box.