Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

=now() date not recognized as date in query

Status
Not open for further replies.

was1

Technical User
Aug 10, 2005
31
US
I created a form for data input with a date field that would automatically populate the current date when the record was being created. I used the =now() in the default value. It works fine. Now, I need to create a query to find all the records for a particular day. When I type in the date in the criteria line of the query, it doesn't return any records. If I manually input the date instead of having it automated, the query will work. What am I doing wrong?

I'm not a programmer so something without code would be great.

Thanks in advance.
 
Now" populates the field with the current date and time. For example, it is NOW 06/06/2008 9:37:11 AM where I live.

If you try to compare that for equality with just the date which is 06/06/2008, they won't match because the date is really 06/06/2008 00:00:00 AM.

Unless the time of day is important to you, use Date() rather than Now()
 
The now() function places the current date and the time. Try using a BETWEEN clause to see if your query results change.

Example...

SELECT myfield FROM mytable WHERE mydate BETWEEN #6/6/2008 00:00:00 AM# AND #6/6/2008 11:59:59 AM#

What happens when you do that?

Are you storing your date values in a string field or a date field?


Gary
gwinn7
 
Thank you!! It works! Wow..what a simple little change and it makes all the difference in the world!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top