Mysql日期函数说明

1、获取当天日期

current_date  ->   2019-07-17 00:00:00

 

2、获取昨天日期函数

date_sub(current_date,INTERVAL 1 day)   ->   2019-07-16 00:00:00

使用举例:

1 select * from `t_settlement_roi` where settlement_date = date_sub(current_date,INTERVAL 1 day)
2 
3 INSERT INTO `t_settlement_roi` (`id`, `merchant_id`, `product_code`, `prod_name`, `settlement_date`, `uv`, `charge_type`, `roi_uv`, `product_price`, `total_register_num`, `register_price`, `cpa_conversion_rate`, `total_settlement_amount`, `del_flag`, `create_time`, `update_time`) 
4 VALUES(NULL,'f5a71edc785f4ce5a9e3cc5daa6ddf1f','54c4ed0d14684934bf4ef3fb687c3435','第三个产品',DATE_SUB(CURRENT_DATE,INTERVAL 1 DAY),'4','2','16.00','11.00','4','16.00','0.2000','64.00','0',CURRENT_DATE,CURRENT_DATE);

 

posted @ 2019-07-17 17:06  星瑞  阅读(239)  评论(0编辑  收藏  举报