Solved

Date Criteria in Access Query

Posted on 2011-03-24
3
527 Views
Last Modified: 2012-08-13
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
Comment
Question by:IslandIT
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 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

by:Carl Tawn
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")

Open in new window

0
 
LVL 33

Expert Comment

by:Mike Eghtebas
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

821 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