Selecting date/time from an Access database
| From: | Metin Kale | Date: | Tue, 25 Nov 2003 20:57:09 +0000 |
| Subject: | Selecting date/time from an Access database | ||
| Groups: | php.db php.windows | ||
| Request: | Send a blank email to php-db+get-31755@lists.php.net to get a copy of this message | ||
Hello all..
I've been tasked to retrieve info from an Access database and I've been successful in selecting data and displaying it. But I do have a problem with DATE/TIME data. When I run a query asking for "TIME" data, I get the value "-1" returned.
<?
$conn = new COM("ADODB.Connection") or die("lala");
$dsn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=FILENAME.mdb";
$conn->Open($dsn);
$rset=new COM("ADODB.Recordset");
$rs=new COM("ADODB.Command");
$rs->Activeconnection=$conn;
$rs->CommandText="SELECT tblBooking.ReservationID, tblBooking.DateBooking, tblRoom.Room, tblBooking.TimeeventStart, tblBooking.TimeBookingEnd
FROM tblRoom INNER JOIN tblBooking ON tblRoom.ID = tblBooking.RoomID ORDER BY tblbooking.reservationid ASC";
$rset=$rs->Execute;
$e= $rset->Fields(4);
$d= $rset->Fields(3);
$c= $rset->Fields(2);
$b= $rset->Fields(1);
$a= $rset->Fields(0);
?>
Results:
$a: 6391
$b: 954568800
$b(formatted from the timestamp above): 4/1/2000
$c: 2D (Minnesota)
$d: -1
$e: -1
$a is the reservation ID
$b is the timestamp
$c is the room name
$d is the start time
$e is the end time
As you can see, both $d and $e are not the correct values. I opened the Access database and checked the data and it returned the correct time. I've never had this kind of problems with MySQL, but I have to use Access in this instance. Has anyone seen this before?
MORE INFO:
PHP Version 4.0.6
Access 97
Thanks,
metin