title: Filter the co-workers who are working right now
body: <p>I've got a table called Work and the columns are </p>
  
  <pre><code>EmployeeID(key), 
  Date (datetime, when the employee checked in to work),
  Work hours (int, the hours he/she will be working for)
  </code></pre>
  
  <p>This is a school project, so I can't modify the tables at all.
  I have to write a select which gives back the ones who are working in that moment, this is what I got so far:</p>
  
  <pre><code>select EmployeeID as Availables, w.Date as Started at
  from Work w
  where datepart(year,w.Date) = DATEPART(year,getdate()) and 
  datepart(month,w.Datum) = datepart(month,getdate()) and
  datepart(day,w.Date) = datepart(day,getdate()) and
  datepart(hour,w.Date) &lt;= datepart(hour,getdate()) and
  datepart(hour,w.Date)+w.WorkHours &gt; datepart(hour,getdate())
  </code></pre>
  
  <p>This solution isn't right, since if I run the query at 01:00 AM, and the employee started the work on the previous day at 23:00 PM (which is possible), then he won't be on the list. 
  I have no idea how to solve this.</p>