How to give specify dates as criteria in Select query

S

subbu

Hi,
I have the requirement to specify date range as
7/30/2003 and 7/01/2002.How to give the same as criterie
in select query

any help in this regard is highly appreciated
subbu
 
R

Raphael Crawford-Marks

SELECT *
FROM YourTable
WHERE YourTable.TheDate > CDate("7/1/2002") AND
YourTable.TheDate < CDate("7/30/2003")

That should work.
 
F

Fredg

Between #7/1/2003# And #7/30/2003#
will limit records to between those dates.


Between [Enter start date] and [Enter end date]
will prompt you to enter the dates, rather than having to hard code the
them.
 
S

subbu

Hi,
Thanks for the code.Is it possible with functions to do
the same instead of prompting

subbu
-----Original Message-----
Between #7/1/2003# And #7/30/2003#
will limit records to between those dates.


Between [Enter start date] and [Enter end date]
will prompt you to enter the dates, rather than having to hard code the
them.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


subbu said:
Hi,
I have the requirement to specify date range as
7/30/2003 and 7/01/2002.How to give the same as criterie
in select query

any help in this regard is highly appreciated
subbu


.
 
F

Fredg

Subbu,
It would be best to use a form in which you can enter the start and end
dates.

Then you would refer to the form in the query criteria, using:
Between forms!NameOfForm!StartDateControl and
forms!NameOfForm!EndDateControl

This way the dates are entered into a form. The query will not prompt.

See the Northwind sample database that is included with Access.
I believe the "Sales by Year" report makes use of this method.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


subbu said:
Hi,
Thanks for the code.Is it possible with functions to do
the same instead of prompting

subbu
-----Original Message-----
Between #7/1/2003# And #7/30/2003#
will limit records to between those dates.


Between [Enter start date] and [Enter end date]
will prompt you to enter the dates, rather than having to hard code the
them.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


subbu said:
Hi,
I have the requirement to specify date range as
7/30/2003 and 7/01/2002.How to give the same as criterie
in select query

any help in this regard is highly appreciated
subbu


.
 

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