Hi,
I'm trying to filter public holidays out of a recordset and am having trouble.
I build a varchar of dates from 1 table and check all records from another table to see if a datefield is IN the varchar - but for somereason it isnt working...I'm really stuck
set nocount on
DECLARE @HolsList varchar(5000)
SElECT @HolsList = COALESCE(@HolsList + ', ', '') + '''' + CONVERT(VARCHAR(8), HolidayDate, 3) + ''''
FROM tblPublicHolidays
SELECT @HolsList -- JUST TO SHOW THE LIST CONTENTS
SELECT LoadedDate, CONVERT(VARCHAR(8), LoadedDate, 3) from CaseDetailsTemp
WHERE CONVERT(VARCHAR(8), LoadedDate, 3) IN (@HolsList)
--where CONVERT(VARCHAR(8), LoadedDate, 3) IN ('08/05/06','02/01/06')
The rem'd out lasdt line works just fine, I have tried every type of format cast and convert on the 'LoadedDate' and on the @HolsList ... But even tho the Select @HolsList shows me exactly what I expected, a string of dates that are comma seperated and each enclosed by apostrophes.
Help please!!!
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).