当前位置: 代码迷 >> .NET Framework >> ASP.NET(C#)中两日期相减,怎么得到相差的月份数
  详细解决方案

ASP.NET(C#)中两日期相减,怎么得到相差的月份数

热度:60   发布时间:2016-05-02 00:58:50.0
ASP.NET(C#)中两日期相减,如何得到相差的月份数?
ASP.NET(C#)中两日期相减,如何得到相差的月份数?

------解决方案--------------------
C# code
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# code
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# code
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;
  相关解决方案