Solved

Where clause for today in a query

Posted on 2014-04-23
5
233 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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