時間:2024-02-07 12:09作者:下載吧人氣:18
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
網友評論