A single date in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In the database i am creating I have a table that contains the date a task
was done along with start and end times. I would like to create a query
which i could later use to create a report that will show all of the tasks
completed on a single day. I have it figured out on how to do a range of
dates but I only want one date. What is the best way to go about doing this?
 
If you have it OK with a date range then surely an end date that is the same
as the start date will give you just one days results ?
 
Thank you for responding so quickly. First i want to make as few steps for
my user as possible so i feel it is just extra work to imput the same date
twice. Also when I do that i recieve no records back. I have a feeling that
it has to do with the fact that there is a time associated with it.
 
In the database i am creating I have a table that contains the date a task
was done along with start and end times. I would like to create a query
which i could later use to create a report that will show all of the tasks
completed on a single day. I have it figured out on how to do a range of
dates but I only want one date. What is the best way to go about doing this?

I like to use a criterion on the Date/TIme field such as
= CDate([Forms]![MyForm]![txtStart]) AND < DateAdd("d", 1, CDate([Forms]![MyForm]![txtEnd]))

The CDate protects you from nonstandard date formats, and the DateAdd
expands the last date to include all times during that date; so you
could enter the same date in both parameters to get all records during
that day.

John W. Vinson[MVP]
 
That does work but it still requires me to enter the same date twice. Is
there anyway to override that and only have to enter it once

John Vinson said:
In the database i am creating I have a table that contains the date a task
was done along with start and end times. I would like to create a query
which i could later use to create a report that will show all of the tasks
completed on a single day. I have it figured out on how to do a range of
dates but I only want one date. What is the best way to go about doing this?

I like to use a criterion on the Date/TIme field such as
= CDate([Forms]![MyForm]![txtStart]) AND < DateAdd("d", 1, CDate([Forms]![MyForm]![txtEnd]))

The CDate protects you from nonstandard date formats, and the DateAdd
expands the last date to include all times during that date; so you
could enter the same date in both parameters to get all records during
that day.

John W. Vinson[MVP]
 
To continue with this question. Is there anyway I can have the entered date
printed at the top of a report.
 
That does work but it still requires me to enter the same date twice. Is
there anyway to override that and only have to enter it once

If you only want to search one date, never a range of dates, just use
= CDate([Forms]![MyForm]![txtStart]) AND < DateAdd("d", 1, CDate([Forms]![MyForm]![txtStart]))

and enter the date only in the txtStart textbox.

John W. Vinson[MVP]
 
Thank you so much for your quick responses, John! I got it all figured out.

John Vinson said:
That does work but it still requires me to enter the same date twice. Is
there anyway to override that and only have to enter it once

If you only want to search one date, never a range of dates, just use
= CDate([Forms]![MyForm]![txtStart]) AND < DateAdd("d", 1, CDate([Forms]![MyForm]![txtStart]))

and enter the date only in the txtStart textbox.

John W. Vinson[MVP]
 
Back
Top