Reputation: 238
I'm wanting to display the data I'm having stored in my database using codeigniter. Currently, the data is stored as a datetime type. I will also need to be able to query for the past month and year, so I'm wondering if there is some functions I haven't found yet that aid in this retrieval.
Here is the codeigniter query I'm using to grab the week's data. What's wrong here?
$this->db
->select_sum('column1')
->select_sum('column2')
->where(YEARWEEK('created_at') == YEARWEEK(NOW()));
Currently, created_at is where the datetime type date is being stored.
Upvotes: 0
Views: 1055
Reputation: 238
(This always happens, doesn't it?)
So, I slept on it. Came into the office, and got it to work just fine.
Here's how my "where previous week" line now looks:
->where('created_at >=', date('Y-m-d', strtotime('-1 week')));
Makes sense, I guess.
Upvotes: 1