Posted by rugger81 on 07/06/06 21:14
I am currently working in the sql server 2000 environment and I want to
write a function to pull all dates within a given date range. I have
created several diferent ways to do this but I am unsatisfied with
them. Here is what I have so far:
declare @Sdate as datetime
declare @Edate as datetime
set @SDate = '07/01/2006'
set @EDate = '12/31/2006'
select dateadd(dd, count(*) - 1, @SDate)
from [atable] v
inner join [same table] v2 on v.id < v2.id
group by v.id
having count(*) < datediff(dd, @SDate, @EDate)+ 2
order by count(*)
this works just fine but it is dependent on the size of the table you
pull from, and is really more or less a hack job. Can anyone help me
with this?
thanks in advance
[Back to original message]
|