How to give specify dates as criteria in Select query

  • Thread starter Thread starter subbu
  • Start date Start date
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
 
SELECT *
FROM YourTable
WHERE YourTable.TheDate > CDate("7/1/2002") AND
YourTable.TheDate < CDate("7/30/2003")

That should work.
 
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.
 
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


.
 
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


.
 
Back
Top