how to get data from database using date between?

Database stored date

item 1: date from :- 10-07-2017 date to :- 20-07-2017
item 2: date from :- 02-07-2017 date to :- 02-08-2017
item 3: date from :- 01-06-2017 date to :- 20-08-2017

input date

start date:- 05-07-2017 end date :- 25-07-2017

here I gave an input date to get data from database. database stored date is the data I want to print. thing is that, which are the items date included in the input date

condition
this are the condition I want to work

start_date < date from && end_date > date_to 
start_date > date from && end_date > date_to 
start_date < date from && end_date < date_to 
start_date > date from && end_date < date_to 

exception case

start_date < end_date < date_to
start_date > end_date > date_to

I want a codeignitor solution . below am giving my model class structure

public function getDate( $start_date = "",$end_date = """)
{
$this->db->select('*');
$this->db->from('user_details');
$this->db->where('');
}


Source: stackoverflow-php

Leave a Reply

Your email address will not be published. Required fields are marked *