Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Dear,
 
I have a Column Name Emp_InTime DataType time(7). The Data is below.
 
Emp_Name             Emp_InTime
A                    08:00:00
B                    08:19:00
C                    08:00:00
D                    09:00:00
 
Now i want to filter who is coming after 08:15:00
 
How to do it in SQL.
 
Thanks
Basit. 


What I have tried:

Select * from Attendance WHERE (Emp_InTime > CONVERT(DATETIME, '2016-05-08 08:15:00', 102))
Posted
Updated 7-May-16 23:29pm

Don't forget that you can put code in the SQL query window and try different things.

This little snippet will help you, I think.
SQL
declare @in_time TIME;
set @in_time = CONVERT(TIME, '08:17:00');
select IIF(@in_time > CONVERT(TIME, '08:15:00'), 'late', 'on time');
go;
 
Share this answer
 
v2
Comments
basitsar 8-May-16 5:32am    
Thanks A lot.
Why are you using a TIME(7) column, and comparing it with a DATETIME?
Just CONVERT to a TIME(7) instead:
SQL
SELECT * FROM Attendance WHERE (Emp_InTime > CONVERT(TIME(7), '2016-05-08 08:15:00', 102))
 
Share this answer
 
Comments
George Jonsson 8-May-16 5:30am    
Hmm, you beat me to it.
You don't need the full date string in this case, right?
OriginalGriff 8-May-16 5:44am    
No, but I suspect he's actually using / passing the current DateTime value, rather than a fixed string.
basitsar 8-May-16 5:31am    
Thanks A lot.
OriginalGriff 8-May-16 5:44am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900