获取上个月和一年的数据

时间:2019-07-23 05:43:06

标签: codeigniter-3

  

如何在2018/12/30之前获取数据

t_report
+------------------------------------------+
| id_report | id_head_report | date_report | 
+------------------------------------------+
| 1         |      3         |  2019/01/30 | 
+------------------------------------------+
| 2         |      2         |  2018/12/30 |
+------------------------------------------+

查询

$id = $this->report_model->get_by_id($id);
$report = $this->db->query("SELECT DATE_FORMAT(date_report, '%m')-01 AS report FROM t_report WHERE id_report=$id")->row()->report;

print_r($ report)

  

1 SELECT DATE_FORMAT(date_report,'%m')-01 AS报告from t_report WHERE id_report = 2

0 个答案:

没有答案