Forums

Find Date

pasqualedi 28 Jan, 2010
Good Morning!
How can find the period date in my table?
If i want search the period from 01/01/2010(dataappuntamento) at 31/01/2010 (dataappuntamento2)...
Please look my code in Where:
<?php
$search_array = array
('provenienza','recordtime','cognome','nome','provincia','cellulare','telefonofisso','città','provincia','tipocontratto','tipoazienda','documentazione','ritardi','pignoramenti','protesti','fattibilità','dataappuntamento','dataappuntamento2','agente','datasospensione');
$where = array();
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
$where[] = " $search LIKE '$value%' ";
}
}
if ( !empty($where) ) {
echo " WHERE ".implode(' AND ', $where);
}?> 
GreyHead 28 Jan, 2010
Hi pasqualedi,

Dates are tricky as you have to make sure that the formatting and date types you use are consistent. Check the MySQL manual for more into.

I'd expect the code to be something like
$where[] = "`date` > '$dataappuntamento' AND `date` < '$dataappuntamento2' ";

But you may need to use some PHP (or extra MySQL code) to put the date values into the correct format for this to work.
Bob
This topic is locked and no more replies can be posted.