如何比较php codeigniter中的日期和年份

My model

public function get_payscale() {
    $this->db->from('payscale P')->join('employee E','E.employee_id = P.employee_id ');
    $this->db->where('P.payscale_date',date('Y-m'));
    return $this->db->get()->result_array();
}   

I want to compare only month and year with the db which in the format y-m-d, where i want only to retrieve the y-m using where clause. any help would be appreciated

Use like this :

$this->db->where('EXTRACT(YEAR_MONTH FROM P.payscale_date)',date('Ym'));

This query will extract the Year and month from the date given column like 201605 (2016-05-21)

Not sure with exact syntax but something like below will work for you.

$this->db->where('year(Start_Date),year(curdate())');
$this->db->where('month(Start_Date),month(curdate())');

I have used the same condition in core PHP you can simply implement it on Codeigniter if any issue gets while implementing let me know

SELECT * FROM `test` WHERE Year('payscale_date') = 2016 and Month('payscale_date') = 05