Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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.

746 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

10 Experts available now in Live!

Get 1:1 Help Now