Very easy to try it in Active Record
$result = $this->db->select('DISTINCT DATE_FORMAT(`t`.`date_field`, "%M %Y") `myformat`', FALSE)->from('my_table `t`')->group_by('MONTH(`t`.`date_field`)')->order_by('t.date_field', 'DESC')->get()->result(); print_r($result);
OR simple request
SELECT DISTINCT DATE_FORMAT(`t`.`date_field`, "%M %Y") `myformat` FROM (`my_table` `t`) GROUP BY MONTH(`t`.`date_field`) ORDER BY `t`.`date_field` DESC;
Output Print Array
[0] => stdClass Object ( [myformat] => August 2011 ) [1] => stdClass Object ( [myformat] => July 2011 ) [2] => stdClass Object ( [myformat] => June 2011 ) [3] => stdClass Object ( [myformat] => March 2011 )
Hope this helps you. Thanks!!
source share