我当前的日期是 2015 年 1 月 10 日。如果我在 codeigniter 中给出如下的 sql 查询,它还会给出类似的日期,1/10/2014,1/10/2013..等。
那么我哪里出错了?
codeigniter 中的 SQL 查询:
function get_birthdate()
{
$this->db->select('fullname as name,avatar,birth_date,user_id',FALSE);
$this->db->from('fx_account_details',FALSE);
$this->db->where('MONTH( birth_date ) = MONTH( CURDATE( ) )
AND DAY( birth_date ) = DAY( CURDATE( ) )
OR (DAY( LAST_DAY( birth_date ) ) =29
AND DAY( birth_date ) =29
AND DAY( LAST_DAY( CURDATE( ) ) ) =28)');
// $this->db->get();
// echo $this->db->last_query();exit;
return $this->db->get()->result();
}
最佳答案
尝试一下可能会有所帮助:
function get_birthdate()
{
$this->db->select('fullname as name,avatar,birth_date,user_id',FALSE);
$this->db->from('fx_account_details',FALSE);
$this->db->where('YEAR( birth_date ) = YEAR( CURDATE( ) AND MONTH( birth_date ) = MONTH( CURDATE( ) )
AND DAY( birth_date ) = DAY( CURDATE( ) )
OR (DAY( LAST_DAY( birth_date ) ) =29
AND DAY( birth_date ) =29
AND DAY( LAST_DAY( CURDATE( ) ) ) =28)');
// $this->db->get();
// echo $this->db->last_query();exit;
return $this->db->get()->result();
}
关于php - 日期年份错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32890169/