Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Date Criteria in Access Query

Posted on 2011-03-24
Medium Priority
543 Views
In our retail store, employees are limited to the number of purchases they can make during our business day, which is from 4:00am - 3:59am (e.g., 3/1/11 4:00am - 3/2/11 3:59am is the March 1st business day) I have an access database that simply keeps track of the number of purchases made. I can do this easily if I only needed to keep track of purchases during the current calendar date, but I can't figure out how to do it for the current business day.

I have a query with the follwing fields: employee ID, timestamp, TransactionCount. To pull transactions for the current calendar day, I just enter "Date()" in the criteria under the Timestamp field. What I need is to see all transactions between today's date @ 4am and tomorrow's date at 3:59am.

Any ideas would be appreciated!
0
Question by:IslandIT
[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

LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 2000 total points
ID: 35206963
try this criteria

Between Date() + timeserial(4,0,0) and Dateadd("d",1,Date()) + timeserial(3,59,0)
0

LVL 52

Expert Comment

ID: 35206988
Probably not the most eleqant solution, but you coudl try:
``````WHERE [Timestamp] Between CDate(Date() & " 04:00") And CDate(Date()+1 & " 03:59")
``````
0

LVL 34

Expert Comment

ID: 35207044
Where Format(PurchaseTime,"yyyy_mm_dd hh:nn")>=Format(Date(),"yyyy_mm_dd 04:00") AND Format(PurchaseTime,"yyyy_mm_dd hh:nn")<=Format(Date()+1,"yyyy_mm_dd 03:59")
0

## Featured Post

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
###### Suggested Courses
Course of the Month4 days, 19 hours left to enroll