Skip to main content
Participant
December 5, 2009
Question

Trying to list 15 days remaing registers ['com_exception' ]

  • December 5, 2009
  • 1 reply
  • 344 views

Dears Sirs,

I've been trying to list 15 days remaing announcements registered on access database using PHP and SQL routines.

I've sucess when doing a quey "select * from BD" without other codes.

Error:

1261306544
2009/12/20
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Unknown<br/><b>Description:</b> Unknown' in C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php:9 Stack trace: #0 C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php(9): com->Execute('select * from P...') #1 {main} thrown in C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php on line 9

Code:

<?php
//Eu preciso fazer uma consulta onde me mostre apenas os registros que irão vencer nos proximos 15 dias
$conexao = new COM("ADODB.Connection");
$conexao->Open(((((("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\wd\\negociofeito\\admin\\dat\\bd.mdb"))))));
    $timestamp = strtotime('+15 days'); // soma 15 dias a data atual
    $comp = date('Y/m/d', $timestamp); //grava data com 15 dias somados
    print $timestamp . "<br/>";
    print $comp;
    $recordset = $conexao->Execute("select * from PRO where (STR_TO_DATE('PRO_DTCAD','Y/m/d') + current_date) >= current_date AND (STR_TO_DATE('PRO_DTCAD','Y/m/d') + current_date) <='$comp'");
    echo "CÓDIGO" . " | " . "NOME" . " | " . "PREÇO" . " | " . "DATA CADASTRO" . " | " . "DURAÇÃO ANÚNCIO" . "<BR/>";
while (!$recordset->EOF) {
    echo " | " . $recordset->fields["PRO_COD"]->value;
    echo " | " . $recordset->fields["PRO_NOME"]->value;
    echo " | " . $recordset->fields["PRO_PRECO"]->value;
    echo " | " . $recordset->fields["PRO_DTCAD"]->value;
    echo " | " . $recordset->fields["PRO_DURAC"]->value;
    echo "<br/>";
    $recordset->MoveNext();
}
$conexao->Close();
?>
This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Participating Frequently
December 6, 2009

I've have no idea if this is it, but queries for MS Access require hash (#) surrounding dates. Try that and see.