date with access2000/php problem
| From: | Stuart McDonald | Date: | Mon, 07 Aug 2000 10:13:35 +0000 |
| Subject: | date with access2000/php problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-1815@lists.php.net to get a copy of this message | ||
Hi all,
I am using PHP to talk to a Access database and am having problems with
dates.
What I need to do is query an events table within the database and pull out
the events which take plave to a certain day - for example, this could by
today, although it could be next Thursday, or all the dates in between.
Now the problem is I can't get the data to match.
In the example below I am trying just to match for today and I know that
there is a matching value in the db.
I use PHP to get the current date via
$today= date("d/m/y",time());
then I attempt tp match it througha select statement as follows:
$event_query= odbc_exec( $cnx, "SELECT e.Date FROM Event e WHERE
e.Date='#$today'");
but I always get this error message:
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type
mismatch in criteria expression., SQL 22005 in SQLExecDirect in ....
or if I use
....WHERE s.Date='$today' or
....WHERE s.Date='#$today#'
I get a Data type mismatch in criteria expression., SQL state 22005
If I use
.....WHERE s.Date=#$today#
Then I get no error but nothing matches either!!
In the Access DB the date is set as a Date/text field in a short date format
and PHP picks todays date and formats it as:
$today= date("d/m/y",time());
I've been looking at this all day and have tried so many things my brain is
really starting to burn, so I think there is something obvious going wrong
that I have overlooked as I wouldn't have thought this would be very
complicated.
Thanks for you help
Stuart