数据处理
是否超时
select case
when TIMESTAMPDIFF(HOUR, tpp.ARCHIVE_DATE,tpp.DEADLINE_TIME) > 48 then '1'
when TIMESTAMPDIFF(HOUR, tpp.ARCHIVE_DATE,tpp.DEADLINE_TIME) > 0
and TIMESTAMPDIFF(HOUR, tpp.ARCHIVE_DATE,tpp.DEADLINE_TIME) <= 48 then '0'
else '-1' end as IS_TIMEOUT,
'是否超时' from table_name tpp
处理时长
select case
IFNULL(TIMESTAMPDIFF(SECOND,NOW(),tpp.DEADLINE_TIME),0) as COMP_DUR_1,
IFNULL(TIMESTAMPDIFF(SECOND,tpp.ARCHIVE_DATE,tpp.DEADLINE_TIME),0) as COMP_DUR_2,
'处理时长' from table_name tpp
时间差计算
select TIMESTAMPDIFF(DAY, '2023-03-20 23:59:00', '2023-03-22 00:00:00');
select TIMESTAMPDIFF(HOUR, '2023-03-20 09:00:00', '2023-03-22 10:00:00');
select TIMESTAMPDIFF(MINUTE, '2023-03-20 09:00:00', '2023-03-22 10:00:00');
select TIMESTAMPDIFF(SECOND, '2023-03-20 09:00:00', '2023-03-22 10:00:00');
SELECT DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -14 MONTH), '%Y/%m/%d')