mysql 时间处理 -常用

时间差---秒

SELECT  floor((TIME_TO_SEC(end_time)-  TIME_TO_SEC(start_time))/60)  FROM `t_ppush_task` where areas=44  order by push_time desc limit 100;

时间-字符串

SELECT  DATE_FORMAT(create_time,'%Y%m%d%H') , sum(recv_num) ,sum(send_num), sum(recv_num) - sum(send_num)
FROM `user_mobile` 
where from_source='zhifengwang' and id > 30000757 and DATE_FORMAT(create_time,'%H') in(12)  group by DATE_FORMAT(create_time,'%Y%m%d%H')  limit 100;

你可能感兴趣的:(mysql)