时间:2024-02-07 12:09作者:下载吧人气:19
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
网友评论