Someone will probablly show you more elegant code, but the basic principle is to create a table containing all dates:create table alldays (datecheck smalldatetime)declare @dateindex smalldatetimeset @dateindex = convert(smalldatetime, '01-Nov-2003')while (@dateindex < convert(smalldatetime, '01-Nov-2004'))begin insert into alldays (datecheck) select @dateindex set @dateindex = dateadd(d, 1, @dateindex)endgo
Then join this table to your dailyvalues table. I've also used the isnull function so that I get 0 for missing days rather than null.select Left(DateName(dw, datecheck), 3) + ' ' + DateName(day, datecheck) + ' ' + Datename(month, datecheck), isnull(dayvalue,0)from DailyValues full outer join alldays on capdate = datecheckwhere datecheck between DateAdd(dd, -7, GetDate()) and GetDate() order by datecheck
enjoy--I hope that when I die someone will say of me "That guy sure owed me a lot of money"