CodeIgniter Mysql日期

I have a problem that i can't fix :(

Well, I have 2 dates and 2 times.

  • 1 date to start publish
  • 1 date to finish publish
  • 1 time to start publish
  • 1 time to end publish

what I need? Show the more recent record, that

  • start publish date is current
  • end publish date is not finished
  • start publish time is current
  • end publish time is not finished

I tried with

start date >= date('Y-m-d') AND
finish date <= date('Y-m-d') AND
(start time) >= date('H:i:s') AND
end time <= date('H:i:s'))

order by ('finish date', 'desc');

In codeIgniter..

->where("start_date >= '{$today}' AND finish_date <= '{$today}'")
 ->where("start_time >= '{$time}' AND finish_time <= '{$time}'")

what i miss?

Thanks

I THINK that I fix it...

(start_date >= $today AND start_time <= $time) AND
(finish_date <= $today AND end_time >= $time)

Well, that works atm...

you need to change the active recods query from

$this->select(*)->from('table')->where("start_date >= '{$today}' AND finish_date <= '{$today}'")
 ->where("start_time >= '{$time}' AND finish_time <= '{$time}'")

to

$this->db->query("SELECT * FROM table WHERE start_date BETWEEN {$today} AND finish_date BETWEEN {$today} AND start_time BETWWEN {$time} AND finish_time BETWWEN {$time}");

return $this->db->get()->result();