DATEPART() 函数用于返回日期/时间的单独部分,比如年、月、日、小时、分钟等等。
DATEDIFF() 函数返回两个日期之间的时间差。
--查找当天上午的数据 select * from R_Attendance where (datepart(hour,RDatetime)>=0 and datepart(hour,RDatetime)<12) and datediff(d,RDatetime,GetDate())=0 --查找当天下午的数据 select * from R_Attendance where (datepart(hour,RDatetime)>12 and datepart(hour,RDatetime)<=23) and datediff(d,RDatetime,GetDate())=0
查看更多关于sqlserver之datepart和datediff应用查找当天上午和下午的数据的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did32268