【问题标题】:I want to get next month record that starts from 1st date of month我想获得从一个月的第一个日期开始的下个月记录
【发布时间】:2015-10-19 09:38:53
【问题描述】:

我正在使用 codeigniter。我想得到下个月的记录。假设今天是 19/10/2015,所以我想要从 01/11/2015 到 30/11/2015 的记录。

我提出了这个查询,但它显示的是从当前日期到 30 天。那么,这可能是什么查询?有什么建议吗?

function get_next_month_birthday()
    {
        $this->db->select('fullname as name,avatar,birth_date,user_id',FALSE);
        $this->db->from('fx_account_details',FALSE);
        $this->db->where('birth_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)');

        return $this->db->get()->result();
    }

【问题讨论】:

    标签: mysql codeigniter


    【解决方案1】:
    $this->db->where('month(birth_date) = month(date_add(last_day(curdate()), interval 1 day)');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 2019-12-01
      • 1970-01-01
      • 2017-02-27
      相关资源
      最近更新 更多