
June 1st, 2006, 09:48 AM
|
|
|
|
Join Date: Apr 2007
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
PEAR::DB connecting to Access via ODBC - problems with dates
I am using the following code to access and query an ms access database.
php Code:
Original
- php Code |
|
|
|
$sql =" SELECT Times.datDate, [Project Details].strProjectName, [Project Details].strCustomer, Times.dblHours, Times.memDescription FROM [Project Details] INNER JOIN Times ON [Project Details].lngProjectID = Times.lngProjectID WHERE Times.datDate Between ? And ?"; $res = $db-> getAll($sql, array("2006-05-01", "2006-06-01") );
the connection works just fine and in my production code there is plenty of error checking.
the problem i have is formatting the dates correctly for inclusion in the query parameter. i have tried just about every combination i can think of and get, variously, empty result sets and errors. MS access seems to want something akin to a number but including the slashes and surrounded by hash signs.
ie
php Code:
Original
- php Code |
|
|
|
between #5/1/2005# And #6/1/2006#
but of course we can't give this type of data in php as the hash sign is a commment designator. yes i could output a specific ascii character but this seems really backwards.
the relevant field type in access is date/time.
does anyone have any experience of how to use dates in queries to access databases across odbc using PEAR  B?
thanks
justin
|