文章分类 -  数据库

摘要:常用SQL时间函数 --基于时间SQL函数--getdate() --返回当前系统日期和时间。DateAdd --在向指定日期加上一段时间的基础上,返回新的 datetime 值。DATEADD ( datepart , number, date )--例:向当天的时间增加5天select dateadd(dd,5,getdate())datediff --返回跨两个指定日期的日期和时间边界数。DATEDIFF ( datepart , startdate , enddate )--例:返回2005-01-01与当天有多少天select datediff(dd,'2005-01-01& 阅读全文
posted @ 2012-01-19 17:54 赤卫 阅读(340) 评论(0) 推荐(0)
摘要:查询本日的记录 select * from tableName where DATEPART(dd, theDate) = DATEPART(dd, GETDATE()) and DATEPART(mm, theDate) = DATEPART(mm, GETDATE()) and DATEPART(yy, theDate) = DATEPART(yy, GETDATE()) 查询本月的记录 select * from tableName where DATEPART(mm, theDate) = DATEPART(mm, GETDATE()) and DATEPART(yy, th... 阅读全文
posted @ 2012-01-19 17:53 赤卫 阅读(458) 评论(0) 推荐(0)