請教SQL 語句.
select top 1000 卡號,
早上=(
select max(cdate) from cardmemo
where cardID=V_考勤時間表.卡號 and
cdate between datediff(mi,V_考勤時間表.有效時長,V_考勤時間表.早上上班) and datediff(mi,-V_考勤時間表.有效時長,V_考勤時間表.早上上班) )
from V_考勤時間表
以上語句返回如下錯誤
Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
但我把 and
cdate between datediff(mi,V_考勤時間表.有效時長,V_考勤時間表.早上上班) and datediff(mi,-V_考勤時間表.有效時長,V_考勤時間表.早上上班)
條件去掉就可以檢索出數據.