Link to home
Start Free TrialLog in
Avatar of NerishaB
NerishaBFlag for South Africa

asked on

SQL - Query with date only from DateTime Field

Hi there,

I have a table that contains the date and time that an employee came to work.  the table is populated everyday, and the time a person came in varies daily.  I want to create a query that will pass only the date, and I want it to return all the employees that came in on that day, regardless of what time it was.  At the moment that field is of type DateTime.

Here is my query:

Select DISTINCT Emp.Name + ' '+ Emp.Surname As FullName, RC.ClockIn
FROM Emp Employees, ClockIns RC
WHERE Emp.Emp_Id = RC.Emp_ID  AND RC.ClockIn = '2010/10/21'

At the moment, it displays no result, but there should be at least one record here.  ClockIn is of type DateTime.
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Hi,
Please use following query

Select DISTINCT Emp.Name + ' '+ Emp.Surname As FullName, RC.ClockIn
FROM Emp Employees, ClockIns RC
WHERE Emp.Emp_Id = RC.Emp_ID  
AND convert(varchar, RC.ClockIn, 101) = '2010/10/21'

Thanks
Avatar of NerishaB

ASKER

Thanks, but that still does not display any result.  
ASKER CERTIFIED SOLUTION
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, they both worked.