ASP.NET计算日期间隔天数
方法一
DateTime t1 = Convert.ToDateTime("2006-1-6");
DateTime t2 = Convert.ToDateTime("2006-1-16");
int day=Math.Abs(((TimeSpan)(t1 - t2)).Days);
方法二
datediff(day,date1,date2)
方法三
DateTime oldDate = new DateTime(2002,7,15);
DateTime newDate = DateTime.Now;
// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;
// Difference in days.
int differenceInDays = ts.Days;
Console.WriteLine("Difference in days: {0} ", differenceInDays);
百家号 互联网微风说

微信公众号 weisico-com

转载请注明:微思考学习网-关注技术,分享知识 >> ASP.NET如何计算两个日期之间相隔天数