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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Comparisons with SQL

Status
Not open for further replies.

dakota81

Technical User
May 15, 2001
1,691
US
I'm not figuring out the correct syntax for creating a recordset object where I'm pulling out records with a specific date. The query I've got started is this:

SELECT * FROM calls WHERE [Next Call Date] =

But I can't quite get it finished. I want to search for the current date, or Now(), but everything I've tried so far either returns an error or doesn't catch the matching records. Any help? I tried testing without the time stamp put in by Now(), by doing DateSerial(Year(Now())... etc. but no luck.
 
You are correct. The proper syntax is...

SELECT * FROM calls WHERE [Next Call Date] = Now()

Are you able to run a reqular query using the Now() or Date() function?

1. You may need to repair and compact your database.
or
2. You may need to open a module. Select Tools from the Menu Bar. Select References. Then look to see if one of your references has a description of "Missing...". If so, uncheck it, close the References window and compact the database.

Hope this helps...

B-)
ljprodev@yahoo.com
ProDev
MS Access Applications
 
SELECT * FROM calls WHERE [Next Call Date] = Now()

Is only going to return the record with the exact matching time. If you want all the records for the current day I should like this:

SELECT
*
FROM
calls
WHERE
Year([Next Call Date]) = Year(Date())
AND
Month([Next Call Date]) = Month(Date())
AND
Day([Next Call Date]) = Day(Date())

 
Thanks for the example, I see now what I overlooked. What I was ending up with each time was my query reading variations on:

SELECT * FROM calls WHERE [Next Call Date] = '6/4/01'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top