One of the basic rules of the universe is that nothing is perfect. Perfection simply doesn't exist. Without imperfection, neither you nor I would exist.
I am trying to filter my sql string to show only data that has been entered on the current date.
It works for a specific date: SQL = "SELECT * FROM VisitorT WHERE VisitorStartDate='5/23/2022 12:53:12 PM' ORDER BY VisitorStartDate DESC "
But I want it for the current date. I keep getting an error when I write it like this:
SQL = "SELECT * FROM VisitorT WHERE VisitorStartDate= " & (Date()) & "ORDER BY VisitorStartDate DESC "
or a variety of other ways.
Can anyone help me with the correct line of code. :-)
Kevin Robertson
@Reply 4 years ago
You are missing a space between the Date function and the Order By clause.
SQL = "SELECT * FROM VisitorT WHERE VisitorStartDate=#" & Date() & "# ORDER BY VisitorStartDate DESC "
Scott Axton
@Reply 4 years ago
One other little subtle thing as well.
In SQL dates need to be surrounded by the # symbol so that Access knows to treat it as a date.
Kevin included it in his response but didn't point it out.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Active Server Pages Forum.