時間:2024-02-07 12:09作者:下載吧人氣:24
DATEPART() 函數(shù)用于返回日期/時間的單獨(dú)部分,比如年、月、日、小時、分鐘等等。
DATEDIFF() 函數(shù)返回兩個日期之間的時間差。
–查找當(dāng)天上午的數(shù)據(jù)
select * from R_Attendance where (datepart(hour,RDatetime)>=0 and datepart(hour,RDatetime)<12) and datediff(d,RDatetime,GetDate())=0
–查找當(dāng)天下午的數(shù)據(jù)
select * from R_Attendance where (datepart(hour,RDatetime)>12 and datepart(hour,RDatetime)<=23) and datediff(d,RDatetime,GetDate())=0
網(wǎng)友評論