ASP.NET(C#)中两日期相减,如何得到相差的月份数?
ASP.NET(C#)中两日期相减,如何得到相差的月份数?
[解决办法]
DateTime startDate = DateTime.Parse("2008-1-1");DateTime endDate = DateTime.Parse("2010-10-31");int totalMonth = endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month;
[解决办法]
C# codeDateTime startDate = DateTime.Parse("2008-1-1");DateTime endDate = DateTime.Parse("2010-10-31");int totalMonth = endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month;
[解决办法]
C# codeDateTime startDate = DateTime.Parse("2008-1-1");DateTime endDate = DateTime.Parse("2010-10-31");int totalMonth = endDate.Year * 12 + endDate.Month - startDate.Year * 12 - startDate.Month;