Welcome Guest, Not a member yet? Register   Sign In
Retrieving results by month...
#1

[eluser]wakey[/eluser]
Hi,

I've been trying to get this sorted for a while and can't seem to get it to work.

I have records in my mysql database that each have column containing the current timestamp as default. I am attempting to select all records from the current month.

I have a feeling I need to use code such as:

Code:
$month = date('n')

$this->db->where('MONTH(current_time)', $month);
$this->db->where('user_id', $uid);
$query = $this->db->get('hits');

I have tried the following SQL statement in my db which returns the value '4' - SELECT MONTH('2010-04-29 23:11:45')

But when I try this statement on my 'current_time' field (which contains current timestamps) it returns NULL.

Does anyone have any ideas?! Any help appreciated! Smile


Messages In This Thread
Retrieving results by month... - by El Forum - 04-29-2010, 04:51 PM
Retrieving results by month... - by El Forum - 04-29-2010, 06:03 PM
Retrieving results by month... - by El Forum - 04-30-2010, 12:40 AM
Retrieving results by month... - by El Forum - 04-30-2010, 01:38 AM
Retrieving results by month... - by El Forum - 04-30-2010, 04:02 AM
Retrieving results by month... - by El Forum - 04-30-2010, 04:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB