[eluser]ywftdg[/eluser]
I had a post about this topic many months ago, back then there was never an answer. Many months later, I have yet to solve this. Can anyone tell help me figuire out why the code below will not work? It is checking to see if the month is January, if so set the year back -1 if they want to run a sales report for "Previous Month." This will not work in my model, anytime I have 2 date statements like that, it results in nothing. I have also defined the querydate variable at the top of my model, that is returning correctly as tested.
Code:
$this->querydate = date("m"); // Get the current date
if ($datepost == '6') { // Last Month BUG
if ( $this->querydate == '1' ) { $this->rollbackyear = '-1'; } // Check Date
$this->db->where('MONTH(rTimeStamp) = MONTH(CURDATE())-1');
$this->db->where('YEAR(rTimeStamp) = YEAR(CURDATE())' . $this->rollbackyear . '');
}