pulling all dates within a date range



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

.



Relevant Pages

  • Re: DATEADD strange results
    ... WHERE invoice_date BETWEEN @sdate AND @edate ... but it doesn't since I can't properly calculate @edate. ... >> first and last possible datetime given a Month and Year. ... > From the documentation: ...
    (microsoft.public.sqlserver.programming)
  • Re: Remove Seconds from Datetime: How To?
    ... truncate the seconds from the datetime. ... It seems very strange to pull the components out of the original ... datetime column, re-assemble them with the stupid ...
    (comp.databases.ms-sqlserver)
  • Getting Just The Date
    ... This sounds stupid, but I cannot find a way to just get today's date without ... the time to pull a date range... ... I have tried convert (datetime, GetDate(), 112) and some others, all to no ...
    (microsoft.public.sqlserver.datamining)
  • Getting Just The Date
    ... This sounds stupid, but I cannot find a way to just get today's date without ... the time to pull a date range... ... I have tried convert (datetime, GetDate(), 112) and some others, all to no ...
    (microsoft.public.sqlserver.programming)
  • Getting Just The Date
    ... This sounds stupid, but I cannot find a way to just get today's date without ... the time to pull a date range... ... I have tried convert (datetime, GetDate(), 112) and some others, all to no ...
    (microsoft.public.sqlserver.clients)