Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have two tables
timesheet-employeeid,startdate
employee-employeeid,employeename,active

if i select a date then i want who is not filling the timesheet on particular day.
i want result in that two columns-
startdate,employeename

i am using this querry it works fine but it show only employeename i want start date also-

C#
SELECT employeename FROM Employee
WHERE active =1 and EmployeeID NOT IN (SELECT EmployeeID FROM TimeSheet WHERE convert(VARCHAR, startdate, 111) = '2012/02/17' ) order by employeename


Thanks in Advance
Posted

SQL
SELECT T.startdate,employeename FROM Employee
LEFT JOIN TimeSheet T ON T.EmployeeID!=EmployeeID

WHERE active =1 and  convert(VARCHAR, T.startdate, 111) = '2012/02/17'
order by employeename
OR

SELECT Convert(datetime, '2012/02/17')   AS startdate,
 employeename FROM Employee
WHERE active =1 and EmployeeID NOT IN (SELECT EmployeeID FROM TimeSheet WHERE convert(VARCHAR, startdate, 111) = '2012/02/17' ) order by employeename
 
Share this answer
 
Comments
mayankshrivastava 24-Feb-12 1:47am    
Thanks alot...
Try this

SQL
Select employeename,startdate From Employee
where active=1 and EmployeeID NOT IN(Select EmployeeID from TimeSheet WHERE convert(VARCHAR, startdate, 111) = '2012/02/17' ) order by employeename
 
Share this answer
 
Comments
mayankshrivastava 24-Feb-12 1:35am    
startdate not in employee table
its in timesheet table

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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