Do a between of 2 columns codeigniter

0

Normally I have made a between on a same column example:

$Where['autos.precio>=']  = 200;
$Where['autos.precio<=']  = 300;

$this->MainModel->listar('autos',$Where,'');

That would bring me all the cars in a price range of 200-300 this is done on a single column that is "price".

  

Now I want to make a between on two different columns   "Reception_date" and "Sale_date":

Date format: YYYY / MM / DD

$Where['autos.fecha_recepcion>=']  = "2017-08-09";
$Where['autos.fecha_venta<=']      = "2017-08-25";

$this->MainModel->listar('autos',$Where,'');

I need to get the vehicles that are between 2 dates on two columns, I hope I have explained well greetings.

    
asked by Javier Antonio Aguayo Aguilar 10.08.2017 в 18:23
source

1 answer

0

Greetings, what I understand is that you need to delimit those fields, what I see is that you only limit one date at a time, it is incomplete. Test as follows:

$Where['autos.fecha_recepcion>=']  = "2017-08-09";
$Where['autos.fecha_recepcion<=']  = "2017-08-25";
$Where['autos.fecha_venta>=']  = "2017-08-09";
$Where['autos.fecha_venta<=']  = "2017-08-25";

$this->MainModel->listar('autos',$Where,'');

I hope it serves you.

    
answered by 16.08.2017 в 22:43