I have two working shifts: 8:00:00 to 16:30:00 and 20:00:00 to 06:00:00.
I want to create a stored procedure that will retrieve data from an SQL table when I pass the date

this are my tables
Table1 Emp

```
ID   DateTime                 EmpID
47   2014-12-05 08:00:00      1111
47   2014-12-05 08:25:00      1235
47   2014-12-05 23:55:00      4569
47   2014-12-06 00:00:00      4563
47   2014-12-06 02:00:00      7412
59   2014-12-06 04:00:00      8523
59   2014-12-05 10:30:00      5632

```

Table2 Product

```
ID     DateTime              ProductMade
47     2014-12-05 11:00:00   Milk
47     2014-12-05 08:00:00   Juice
47     2014-12-06 00:00:00   Bread
47     2014-12-06 06:00:00   Cakes

```

query for shift 2 18:00 to 06:00

```
SELECT *  
FROM Table 1  as T1 
INNER JOIN Table_Product as Prod ON t1.ID=Prod.ID 
WHERE  T1.DateTime BETWEEN DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()-8), 0) + '18:00'
AND DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()-7), 0) + '06:00'

```

so this will get all the records that has the same ID matching

then i have to do another query for the first shift.

between 08:00 to 16:30 

```
SELECT *  
FROM Table 1  AS T1
INNER JOIN
Table_Product AS Prod ON t1.ID=Prod.ID  
WHERE  DATEDIFF(day, CONVERT(VARCHAR(10), GETDATE(),110), CONVERT(VARCHAR(10), T1.DateTime,110))=-1 AND DATEPART(HOUR,T1.DateTime) BETWEEN '07' AND '16'

```

How do i make this into one stored procdure and elminate having two queries.