date criteria or all

D

DD

i have a query that i enter begin dates and end dates. i want to be able
also to get all record simly be entering a null in the dates field. is this
possible.

thanks
 
K

Ken Snell [MVP]

Yes.

SELECT *
FROM YourTable
WHERE (DateField Between [Enter start date:] And [Enter end date:])
OR ([Enter start date:] Is Null And [Enter end date:] Is Null);
 
D

Douglas J. Steele

Or, if you'd prefer to, say, only enter a start date but no end date (or
vice versa)

SELECT *
FROM YourTable
WHERE (DateField Between Nz([Enter start date:], #1/1/100#)
And Nz([Enter end date:], #12/31/9999#)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken Snell said:
Yes.

SELECT *
FROM YourTable
WHERE (DateField Between [Enter start date:] And [Enter end date:])
OR ([Enter start date:] Is Null And [Enter end date:] Is Null);
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


DD said:
i have a query that i enter begin dates and end dates. i want to be able
also to get all record simly be entering a null in the dates field. is
this possible.

thanks
 
D

Douglas J. Steele

Oops. Incorrect parentheses.

SELECT *
FROM YourTable
WHERE DateField BETWEEN Nz([Enter start date:], #1/1/100#)
AND Nz([Enter end date:], #12/31/9999#)

or

SELECT *
FROM YourTable
WHERE (DateField BETWEEN Nz([Enter start date:], #1/1/100#)
AND Nz([Enter end date:], #12/31/9999#))

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Douglas J. Steele said:
Or, if you'd prefer to, say, only enter a start date but no end date (or
vice versa)

SELECT *
FROM YourTable
WHERE (DateField Between Nz([Enter start date:], #1/1/100#)
And Nz([Enter end date:], #12/31/9999#)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken Snell said:
Yes.

SELECT *
FROM YourTable
WHERE (DateField Between [Enter start date:] And [Enter end date:])
OR ([Enter start date:] Is Null And [Enter end date:] Is Null);
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


DD said:
i have a query that i enter begin dates and end dates. i want to be able
also to get all record simly be entering a null in the dates field. is
this possible.

thanks
 

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