Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord, MySQL with DATE_SUB ... how?
#5

[eluser]hugle[/eluser]
[quote author="cahva" date="1254712837"]You dont actually have to use DATE_SUB at all. This is perfectly valid query:
Code:
SELECT CURDATE() - INTERVAL 31 DAY;

For the AR this should work:
Code:
$this->db->where('(CURDATE() - INTERVAL 31 day) > created2');

If the query fails, you can check the last query with
Code:
echo $this->db->last_query();
[/quote]

Thanks for your suggestions cahva!
Code:
$this->db->where('(CURDATE() - INTERVAL 31 day) > razrabotki.created');
this one works tooSmile so it is better to avoid DATE_SUB? thanks!

but this one didn't work:
[code
$this->db->where('(CURDATE() - INTERVAL 31 day) > created2');
[/code]

O was getting error Unknown column 'created2' in 'where clause' ...
thanks guys for helping me !


Messages In This Thread
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 11:12 AM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 03:33 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:20 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:39 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:44 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-06-2009, 04:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB