Dears Sirs,

I'm brazillian, sorry my horrible english.
I've been trying to do a quey that shows registers with 15 days remaining

----------------

I see an 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

And the code is:

<?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 a 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();
?>

Dears Sirs,

I'm brazillian, sorry my horrible english.
I've been trying to do a quey that shows registers with 15 days remaining

----------------

I see an 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

And the code is:

<?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 a 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();
?>

what is ur problem. do you want to display last 15 days user. if so

"select * from PRO where  date_added >= DATE_SUB(CURDATE(), INTERVAL 15 DAY) "

write select query like this and try it. my query posted here modify it .

"select * from PRO where  date_added >= DATE_SUB(CURDATE(), INTERVAL 15 DAY) "

write select query like this and try it. my query posted here modify it .

Tanks brother but,

I did this:
PRO_DTCAD + PRO_DURAC (duration)...
As a:
"select * from PRO where PRO_DTCAD + PRO_DURAC > NOW() AND PRO_DTCAD < NOW()+15"

But I see this error:

1261316259
2009/12/20CÓDIGO | NOME | PREÇO | DATA CADASTRO | DURAÇÃO ANÚNCIO
| 180 | Galpão - Leopoldina -MG | 0 | 0080717 | 30

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft JET Database Engine<br/><b>Description:</b> Tipo de dados imcompatível na expressão de critério.' in C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php: 18 Stack trace: #0 C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php( 18): variant->MoveNext() #1 {main} thrown in C:\wd\xampp\htdocs\nf\admin\consulta_vencendo.php on line 18

Something like DATA TYPE INCOMPATIBLE.

Becouse, 20080717 + 30 isn't 20080747...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.