Select all dates between two dates (AC2007)

jeudi 9 avril 2015

Hi guys,



I have a table of records, which has within it two date fields (effectively, a 'start' and 'end' date for that particular record)



I now need to create a query to perform a calculation for each date between the 'start' date and the 'end' date



So the first step (as I see it anyway) is to try to create a query which will give me each date between the two reference dates, in the hope that I can then JOIN that onto another query to perform the necessary calculation for each of the returned dates.



Is there a way to do this?



So basically, if for a particular record, the 'start' date is 01-Apr-2015 and the 'end' date is 09-Apr-2015, can I produce a dataset of 9 records as follows :
01-Apr-2015

02-Apr-2015

03-Apr-2015

04-Apr-2015

05-Apr-2015

06-Apr-2015

07-Apr-2015

08-Apr-2015

09-Apr-2015

(The *obvious* solution would be to create a separate table of dates, from which I could just SELECT DISTINCT <Date> Between #04/01/2015# And #04/09/2015# - but that seems like a dreadful waste of space, if that table is only required to generate the above? And it would have to cover all possible options; so it would either have to be massive, and contain every possible date - ever! - or maintained, adding new dates as necessary when they are required. Seems horribly inefficient!)



Is it possible to just select each date between the two reference dates? Or can you only query something which exists somewhere in a table?



Thanks!



Al

Select all dates between two dates (AC2007)

0 commentaires:

Enregistrer un commentaire

Labels