专注

导航

计算两个日期相隔的天数

   1:          /// <summary>
   2:          /// 计算两个日期相隔的天数
   3:          /// </summary>
   4:          /// <param name="startdate">开始日期</param>
   5:          /// <param name="enddate">结束日期</param>
   6:          /// <returns></returns>
   7:          public static int GetDayInterval(DateTime startdate, DateTime enddate)
   8:          {
   9:              TimeSpan sts = new TimeSpan(startdate.Ticks);
  10:              TimeSpan ets = new TimeSpan(enddate.Ticks);
  11:              int days = ets.Subtract(sts).Duration().Days;
  12:              return days;
  13:          }
}

posted on 2011-11-13 11:23  陈啊M  阅读(224)  评论(0编辑  收藏  举报