PBaldy, I solved my issue by creating 2 SQL views in SQL Server 2005. The first one creates a crosstab of all dates between the beginning date and the ending date. The second is a union query that puts all the data into one column and selects out the dates that are Saturday and Sunday.
this is a snippet of the first view
SELECT RecID, EmpID, BeginDate, EndDate, 'Date1' =
CASE
WHEN DATEDIFF(day,BeginDate,EndDate+1) >= 1 Then [BeginDate]
End,
'Date2' =
CASE
WHEN DATEDIFF(day,BeginDate,EndDate+1) >= 2 Then [BeginDate] +1
End
From tblFTODetail
Here's a snippet of the second view
SELECT RecID, EmpID, BeginDate, EndDate, Date1 AS RequestDate
FROM vw_CrosstabRequestDates
WHERE (Date1 IS NOT NULL) And DatePart(dw,Date1) <> 7 and DatePart(dw,Date1) <> 1
Union SELECT RecID, EmpID, BeginDate, EndDate, Date2 AS RequestDate
FROM vw_CrosstabRequestDates
WHERE (Date2 IS NOT NULL) And DatePart(dw,Date2) <> 7 and DatePart(dw,Date2) <> 1
from FTODetail
Here's the result for one employee: The last field is what I need
1 888888 10/12/2009 12:00:00 AM 10/16/2009 12:00:00 AM 10/12/2009
1 888888 10/12/2009 12:00:00 AM 10/16/2009 12:00:00 AM 10/13/2009
1 888888 10/12/2009 12:00:00 AM 10/16/2009 12:00:00 AM 10/14/2009
1 888888 10/12/2009 12:00:00 AM 10/16/2009 12:00:00 AM 10/15/2009
1 888888 10/12/2009 12:00:00 AM 10/16/2009 12:00:00 AM 10/16/2009
Works like a charm and no code required.
Thanks for attempting to help me