您的位置:首页 > 其它

求两个日期之间相隔的天数

2007-09-10 19:59 274 查看
public int DiffDay(DateTime d1, DateTime d2) //得到日期相减之后的值
{
try
{
if (d1 > d2) return (int)((TimeSpan)(d1 - d2)).TotalDays;
else return (int)((TimeSpan)(d1 - d2)).TotalDays;
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: