Solved

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

Posted on 2014-04-17
2
980 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
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now