?
Solved

Adding calculated date to Between clause

Posted on 2011-03-17
6
Medium Priority
?
186 Views
Last Modified: 2012-05-11
Should be easy, but I'm just too tired of messing with this.  I have a simple query that I need to pull records based off of yesterday at 7am to today at 7am. Hard coding the between clause works fine.

Between #3/16/2011 7:00:00 AM# And #3/17/2011 7:00:00 AM#

However I need to do something like this.

Between date()-1& #7:00:00 AM# And date() & #7:00:00 AM#

This is returning an error.
0
Comment
Question by:bhieb
[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
6 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 35156822
Use Dateadd(d,date(),-1)
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 35156834
This should work,
BETWEEN Date() + #07:00:00# AND (Date() + 1 + #07:00:00#)

although this would include values for 07:00 tomorrow.  I prefer to use:

>= Date() AND < (Date() + 1 + #07:00:00#)
0
 

Author Comment

by:bhieb
ID: 35156837
But how to I concatenate the time in there. date()-1 works fine to get me to yesterdays date it is the concatenating 7am into it that is the issue.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 35156840
use the "+" sign instead of "&"


Between date()-1 + #7:00:00 AM# And date() + #7:00:00 AM#
0
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 1000 total points
ID: 35156858

Sorry, that should have been:

>= Date() -1 + #07:00:00#  AND < Date() + #07:00:00#
0
 

Author Comment

by:bhieb
ID: 35156879
Perfect. Dang I should have remembered that + is concatenate from my SQL days. DOH!
0

Featured Post

Technology Partners: 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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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

762 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