我用它来获取今天的记录。
$this->db->where('date(BaseTbl.createdDtm)', date('Y-m-d'));
如何获得本月的纪录?有人请建议吗?
答案 0 :(得分:0)
尝试此查询它会帮助您
SELECT * FROM table WHERE MONTH(columnName) = MONTH(CURRENT_DATE())
答案 1 :(得分:0)
只使用mysql就可以了:
SELECT *
FROM table_name
WHERE YEAR(BaseTbl.createdDtm) = YEAR(CURRENT_DATE()) AND
MONTH(BaseTbl.createdDtm) = MONTH(CURRENT_DATE());
修改强>
对于codeigniter
$this->db->where('YEAR(BaseTbl.createdDtm))', date('Y'));
$this->db->where('MONTH(BaseTbl.createdDtm))', date('m'));