December 11, 2008 at 9:44 pm
Friends,
How to get all the rows in the below mentioned table that matching the condition of checkInTime less than 2 hours of currenttime?
TableName -> EducationDepartment
Columns -> empID, checkInTime (datetime).
I need to get all the employee ID's who's working hour is greater than 2 hours i.e GetDate() - checkInTime > 2.
Please help me on this.
December 11, 2008 at 9:54 pm
sunil.si (12/11/2008)
Friends,How to get all the rows in the below mentioned table that matching the condition of checkInTime less than 2 hours of currenttime?
TableName -> EducationDepartment
Columns -> empID, checkInTime (datetime).
I need to get all the employee ID's who's working hour is greater than 2 hours i.e GetDate() - checkInTime > 2.
Please help me on this.
select empID from EducationDepartment where empId in (select distinct empID from EducationDepartment where Datepart(hour, getdate())<2 and empID is not null)
hope that can help you.
December 11, 2008 at 10:17 pm
Select empid,checkintime from EducationDepartment
WHERE DATEDIFF(ss,checkintime,getdate()) < 7200.
I have converted 2 hrs into seconds to get as much correct results as possible.
"Keep Trying"
December 11, 2008 at 10:39 pm
Thanks friends, & it worked!
December 12, 2008 at 12:37 am
Can anyone help to find the syntax error in this query?
@query = 'select empID from EducationDepartment where DateDiff(hh, checkInTime, getdate()) > 2 and userPriority = 1 and status != "closed"'
Thx,
Linus
December 12, 2008 at 12:42 am
sunil.si (12/12/2008)
Can anyone help to find the syntax error in this query?@query = 'select empID from EducationDepartment where DateDiff(hh, checkInTime, getdate()) > 2 and userPriority = 1 and status != "closed"'
Thx,
Linus
Probably the doublequotes here status != "closed"'
But more importantly - why are you running this as dynamic sql? It should run just fine as it is.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 12, 2008 at 5:34 am
Hi Chris,
u r right & the double quotes created the problem... thx for the help!...
Thx,
Linus
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply