Access db problem trying to retieve date
am 08.08.2006 17:21:32 von jtrainaldi
Basically I am trying to access all entries from a database that equal
the current system date.
I am using an ASP page accessing an ACCESS DB. I am not getting any
errors but the database is not retrieving anything. However, when I do
a SELECT * FROM Events i get everything.
My code is:
SQL_query = "SELECT * FROM Event WHERE eventDate= 8/24/2006"
or
SQL_query = "SELECT * FROM Event WHERE eventDate= " & date
I tried both strings. The one was used to see if the code would work
if it was hard coded.
I was wondering if I am doing anything wrong. Please help me.
Re: Access db problem trying to retieve date
am 08.08.2006 17:44:42 von reb01501
jtrainaldi@gmail.com wrote:
> Basically I am trying to access all entries from a database that equal
> the current system date.
>
> I am using an ASP page accessing an ACCESS DB. I am not getting any
> errors but the database is not retrieving anything. However, when I
> do a SELECT * FROM Events i get everything.
>
> My code is:
>
> SQL_query = "SELECT * FROM Event WHERE eventDate= 8/24/2006"
I thought you wanted the current system date ... today is 8/8/2006. You
should supply dates in ISO format (yyyy-mm-dd) so there is no month-day
confusion.
Jet requires date literals to be delimited with # symbols (...WHERE
eventdate = #2006-08-24#). However, Jet can use VBA functions such as
Date() ... see below:
>
> or
>
> SQL_query = "SELECT * FROM Event WHERE eventDate= " & date
>
> I tried both strings. The one was used to see if the code would work
> if it was hard coded.
>
> I was wondering if I am doing anything wrong. Please help me.
If you are not storing the time of day in the field, then this will
work:
SQL_query = "SELECT * FROM Event WHERE eventDate=Date"
If you are storing time as well as date in the field, then
SQL_query = "SELECT * FROM Event WHERE " & _
"eventDate>=Date AND eventDate < DateAdd('d',1,Date)"
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.