几条常用 关于时间的 处理

查询当天的内容:select * from article where  datediff(day,时间字段,getdate())=0

 本周:select * from article where  datediff(week,时间字段,getdate())=0

DateTime dd = (DateTime)ds.Tables[0].Rows[i]["pubdate"];

if (DateTime.Now.Date < dd.Date.AddDays(30))
{
                System.TimeSpan timeSpan = (System.TimeSpan)(DateTime.Now - dd.Date);
                ds.Tables[0].Rows[i]["day"] = timeSpan.Days.ToString() + "天前";
}

原文地址:https://www.cnblogs.com/terrorpig/p/1371778.html