Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access date field display 1

Status
Not open for further replies.

BPMan

Programmer
Jun 25, 2002
163
US
I am displaying date fields that i get from a MS Access database. I Query the database and when i output the information the fields that are stored as dates just come out as numbers like 10940720094. Is there some easy way to output them correctly...
here is some of my code..


$db_connection = new COM("ADODB.Connection");

$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".
realpath("../ceq/CEDatabase.mdb") ." ;DefaultDir=". realpath("../ceq");
$db_connection->open($db_connstr);

// make forms to select with
echo &quot;<form method=\&quot;post\&quot; action=\&quot;index.php\&quot;><table><tr><td>Company Name</td><td>&quot;.
&quot;<SELECT NAME=\&quot;compName\&quot;>&quot;;

$rs1 = $db_connection->execute(&quot;SELECT [Company Name] FROM Presentation GROUP BY [Company Name]&quot;);
$rs1_fld0 = $rs1->Fields(0);


while (!$rs1->EOF) {
echo&quot;<OPTION VALUE=\&quot;$rs1_fld0->value\&quot;>$rs1_fld0->value&quot;;
$rs1->MoveNext();
}
echo&quot;</SELECT></td>&quot;;

echo &quot;<td>Commodity</td><td>&quot;.
&quot;<SELECT NAME=\&quot;commodity\&quot;>&quot;;

$rs2 = $db_connection->execute(&quot;SELECT [Commodity] FROM Presentation GROUP BY [Commodity]&quot;);
$rs2_fld0 = $rs2->Fields(0);

while (!$rs2->EOF) {
echo&quot;<OPTION VALUE=\&quot;$rs2_fld0->value\&quot;>$rs2_fld0->value&quot;;
$rs2->MoveNext();
}

echo&quot;</SELECT></tr></td>&quot;;
echo&quot;</table></form>&quot;;


// build table based on selections above
$rs = $db_connection->execute(&quot;SELECT * FROM Presentation&quot;);
$rs_fld0 = $rs->Fields(0);
$rs_fld1 = $rs->Fields(1);
$rs_fld2 = $rs->Fields(2);
$rs_fld3 = $rs->Fields(3);
$rs_fld4 = $rs->Fields(4);
$rs_fld5 = $rs->Fields(5);
echo &quot;<table border=1><tr><th>ID</th><th>Company Name</th>&quot;.
&quot;<th>Description</th><th>Date Recieved</th><th>Commodity</th><th>Location</th></tr>\n&quot;;

while (!$rs->EOF) {
echo &quot;<tr><td nowrap>$rs_fld0->value</td><td nowrap>$rs_fld1->value</td>&quot;.
&quot;<td nowrap>$rs_fld2->value</td><td nowrap>$rs_fld3->value</td><td>$rs_fld4->value</td><td nowrap>$rs_fld5->value</td></tr>\n&quot;;

$rs->MoveNext(); /* updates fields! */
}
echo &quot;<tr><td colspan=2> </td></tr></table>&quot;;
$rs->Close();
$db_connection->Close();

the date received field is a date but it just outputs numbers...
thanks
 
i was just inputing improperly...
basicially i was saying something like
echo &quot;date(blah)&quot;;
instead of
echo date(blah);
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top