[eluser]predat0r[/eluser]
Hey,
I have a DATE (example: 2011-05-23) in my table and want to filter by year and month, with this date structure. I know (guess) I can use mysql MONTH() or DATE_FORMAT() functions but how to implement them?
I tried to put MONTH in the
like or
where statements but gets error, and DATE_FORMAT in the
select, with no success..
My code snippet:
$query_array contains the filter options from dropdowns, for example evek = 2010, and honapok = 05
To be honest, filtering by year works, because there are only one 2010, but for month, 05 could be a month or a day, or a part of a year also..
Code:
function get_all_galleries($query_array, $limit, $offset) {
$query = $this->db->select("id, datum, title, folder_name")
->from('galeriak')
->where('status', 'aktiv')
->order_by('datum', 'DESC')
->limit($limit, $offset);
if(strlen($query_array['evek'])) {
$query->like('datum', $query_array['evek']);
}
if(strlen($query_array['honapok'])) {
$query->like('datum', $query_array['honapok']);
}
$data['content'] = $query->get()->result();
....
thank you