我有一张表可以存储员工休假开始日期和结束日期 像这样:
EmployeeID ManagerId leaveStartDate leaveEndDate isApproved
1 14 10/02/2014 15/02/2014 approved
4 17 10/02/2014 12/02/2014 rejected
我需要检查经理登录是否有任何员工休假?如果是,那么经理可以将员工分配给其他员工。为此,我必须检查当前系统时间是否在LeaveStartDate和leaveEndDate之间。我可以这样做吗?
答案 0 :(得分:0)
试试这个:
这可以解决这个问题:
* abc是您的表名
select * from abc where isApproved="approved" and Date(Getdate()) between leaveStartDate and leaveEndDate
答案 1 :(得分:0)
如果您想过滤IsApprved,请尝试这样做。
SELECT * FROM tblEmployeeLeaves WHERE Date(Getdate()) between leaveStartDate and leaveEndDate AND isApproved='approved'
答案 2 :(得分:0)
工作得非常感谢
select EmployeeId from tblName where Getdate() between leaveStartDate and leaveEndDate and isApproved='Approve' and ManagerId=@mgrId