NerishaB
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.
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.
ASKER
Thanks, but that still does not display any result.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, they both worked.
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