Solved

How query data using date part of a date/time field

Posted on 2014-04-17
2
987 Views
Last Modified: 2014-04-17
In a table I have a date/time field that looks like this for example:

4/16/2014 12:43:41 PM

But I want to query records using just the date part of that information.

My query criteria looks like:

Between [Forms]![frmSelectDatesForLaborTranxReport]![txtStart] And [Forms]![frmSelectDatesForLaborTranxReport]![txtEnd]

But I 'm sure I have to change it somehow to return the records that have 4/16/2014 or whatever date range is entered in frmSelectDatesForLaborTranxReport

How can I do this?

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40006657
You can use DateValue:

WHERE DateValue(YourDateField) BETWEEN [Forms]![frmSelectDatesForLaborTranxReport]![txtStart] And [Forms]![frmSelectDatesForLaborTranxReport]![txtEnd]
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40006682
No points please.  I agree with Scott on use of the DateValue ( ), but I don't like using BETWEEN with date fields.  Personally, I would use:

WHERE DateValue([YourDateField]) >= Forms![frmSelectDatesForLaborTranxReport]!txtStart]
AND DateValue([YourDate]) <= Forms![frmSelectDatesForLaborTranxReport]!txtEnd]

Actually, I generally use:

WHERE [YourDateField] >= Forms![frmSelectDatesForLaborTranxReport]!txtStart]
AND [YourDate] < DateAdd("d", 1, Forms![frmSelectDatesForLaborTranxReport]!txtEnd])
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question