?
Solved

Where clause for today in a query

Posted on 2014-04-23
5
Medium Priority
?
234 Views
Last Modified: 2014-04-23
My where clause that is suppose to bring up the records from the current day is not working. The where clause is:

WHERE (((DateValue(Nz([qryBookingDayswithYearIIIB].[DayRecorded],#1/1/1950#)))=DateValue(Now())) AND ((qryBookingDayswithYear.FirstDay)=[qryBookingDayswithYearIIIB].[DayRecorded]))

Open in new window


I am using a very similar where clause in another query that pulls up the records from the current week. This work perfectly. It is:

WHERE (((Format(Nz([qryBookingDayswithYearIIIB].[DayRecorded],#1/1/1950#),"wwyy"))=Format(Now(),"wwyy")) AND ((qryBookingDayswithYear.FirstDay)=[qryBookingDayswithYearIIIB].[DayRecorded]))

Open in new window


Is there a way I can change my first where clause for current day that would work properly. When a originally designed this query it was working properly... that was a month ago. Not sure why it is not working. Thanks!
0
Comment
Question by:cansevin
[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
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40017585
The trick is what you said 'very similar'. Look at this section:

[DayRecorded],#1/1/1950#),"wwyy"))=Format(Now(),"wwyy"))

[DayRecorded],#1/1/1950#)))=DateValue(Now())

Make sure your date formats match or they will never return what you need.
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40017596
Another thought. You can look at the data when the query was working. Maybe something changed in the way the data was entered.
0
 

Author Comment

by:cansevin
ID: 40017603
Jmiller, thanks for you help. At the risk of looking stupid... what do you think I should do to solve it? Is there I way I can make the first where look like the 2nd where an work for the current day?

Thanks for your help!
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40017624
try this


WHERE (((Format(Nz([qryBookingDayswithYearIIIB].[DayRecorded],#1/1/1950#),"yyyymmdd"))=Format(Now(),"yyyymmdd")) AND ((qryBookingDayswithYear.FirstDay)=[qryBookingDayswithYearIIIB].[DayRecorded]))
0
 

Author Closing Comment

by:cansevin
ID: 40017775
Thanks!!!
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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