pulling all dates within a date range
- From: "rugger81" <jgilchrist@xxxxxxx>
- Date: 6 Jul 2006 14:14:40 -0700
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
.
- Follow-Ups:
- Re: pulling all dates within a date range
- From: Erland Sommarskog
- Re: pulling all dates within a date range
- From: Hugo Kornelis
- Re: pulling all dates within a date range
- Prev by Date: Re: Odd SQL IN usage?
- Next by Date: Re: pulling all dates within a date range
- Previous by thread: Insert Subqueries
- Next by thread: Re: pulling all dates within a date range
- Index(es):
Relevant Pages
|