Date Range Query

B

Billiam

How would you make a query that would list all the dates occurring between
Date1 and Date2 , including Date1 and Date2?

Thanks,

Billiam
 
S

Stefan Hoffmann

hi Billiam,
How would you make a query that would list all the dates occurring between
Date1 and Date2 , including Date1 and Date2?
You need a condition like this as SQL

SELECT *
FROM yourTable
WHERE minDate <= yourDateField
AND yourDateField <= maxDate

You may also take a look at the BETWEEN operator.

mfG
--> stefan <--
 
B

Billiam

Hi Stefan,

Thanks very much for the information, I will definately look up the Beween
Operator.

I am planning on using unbound comboboxes for the cboDateFrom and
cboDateTo...will this still work, or do i have to have an underlying table of
dates?

Thanks,

Billiam
 
S

Stefan Hoffmann

hi Billiam,
I am planning on using unbound comboboxes for the cboDateFrom and
cboDateTo...will this still work, or do i have to have an underlying table of
dates?
As you can reference them in queries as
[Forms]![yourFormName]![cboDateFrom] this will work.

mfG
--> stefan <--
 
B

Billiam

Thanks so much for your help, Stefan!
Have a great weekend!

Billiam

Stefan Hoffmann said:
hi Billiam,
I am planning on using unbound comboboxes for the cboDateFrom and
cboDateTo...will this still work, or do i have to have an underlying table of
dates?
As you can reference them in queries as
[Forms]![yourFormName]![cboDateFrom] this will work.

mfG
--> stefan <--
 
B

Billiam

Hi Stefan,

I'm afraid i am at a loss how to do this from your examples, and the Between
operator seems to just evaluate if a date falls in a range, whereas i need to
produce a list of each day in the range...have i misunderstood your
directions? Would you clarify the proper syntax for the query?

Lost in query land,

Billiam

Stefan Hoffmann said:
hi Billiam,
I am planning on using unbound comboboxes for the cboDateFrom and
cboDateTo...will this still work, or do i have to have an underlying table of
dates?
As you can reference them in queries as
[Forms]![yourFormName]![cboDateFrom] this will work.

mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Billiam,
I'm afraid i am at a loss how to do this from your examples, and the Between
operator seems to just evaluate if a date falls in a range, whereas i need to
produce a list of each day in the range...have i misunderstood your
directions?
I would say it's vice versa.
Would you clarify the proper syntax for the query?
So you have to dates and would get a list - as a query - of days between
them?

In this case you need a additional table holding the numbers from 1 to
365. Basically it must look like this:

SELECT DateAdd("d", T.number, T.number)
FROM numberTable T
WHERE DateAdd(minDate, T.number) <= maxDate

mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top