RE: [PHP-DB] date with access2000/php problem

From: Date: Mon, 07 Aug 2000 10:26:39 +0000
Subject: RE: [PHP-DB] date with access2000/php problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1816@lists.php.net to get a copy of this message
Your last attempt is the correct syntax: WHERE s.date=#$today# I think you may be getting internal truncation errors in Access. Even though you specified a small date, Access secretly stores it as a timestamp. How about trying: WHERE cdate(Format(mydate,"d/m/y"))=($today) BTW: You may experience problems with date formats on other machines (if you port your DB or upsize it to SQL Server). I always use the date format: DD MMM YYYY (e.g. 07 AUG 2000) just in case. Hope this helps... _____ ~ Richard Allsebrook ~ Applications Developer and Webmaster Easysoft Limited, No3 The Embankment, Leeds, LS1 4BJ http://www.easysoft.com <http://www.easysoft.com> The Home of Data Access Middleware "A computer lets you make more mistakes faster than any invention in human history-with the possible exceptions of handguns and tequila." _____ -----Original Message----- From: Stuart McDonald [mailto:stuart@fourelephants.com] Sent: Monday, August 07, 2000 11:14 AM To: php-db@lists.php.net Subject: [PHP-DB] date with access2000/php problem 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#1816) next »