/**有一个需求,要求获得两个日期想减的天数,小时数,分钟数。通过查找资料,于是乎我写出了如下代码,来获得两个字段。*/
IFNULL(CONCAT( IF(aib.`forecast_reply_time`-aib.`actual_reply_time` < 0,'-',''),
IF(FLOOR(HOUR(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`)) / 24)=0,'', CONCAT(FLOOR(HOUR(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`)) / 24),'天')),
IF(MOD(HOUR(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`)), 24)=0,'',CONCAT(MOD(HOUR(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`)), 24), '小时')),
IF(MINUTE(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`))=0,'',CONCAT(MINUTE(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`)), '分钟'))),"") AS stipulatedOften,
IFNULL(CONCAT(
IF(FLOOR(HOUR(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`)) / 24)=0,'', CONCAT(FLOOR(HOUR(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`)) / 24),'天')),
IF(MOD(HOUR(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`)), 24)=0,'',CONCAT(MOD(HOUR(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`)), 24), '小时')),
IF(MINUTE(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`))=0,'',CONCAT(MINUTE(TIMEDIFF(aib.`created_at`,aib.`actual_reply_time`)), '分钟'))),"") AS actualOften,
/**后来需求改变,用户觉得现实中文的天,小时,分钟太麻烦了,想要总共的小时数、分钟数,但是mysql的TIMEDIFF的方法,是精确到秒的,但是用户又不想要秒。于是乎我又一次进行了更改,使用到了mysql的LEFT函数和LENGTH函数进行了处理弄成了用户想要的样子*/
IFNULL(LEFT(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`),LENGTH(TIMEDIFF(aib.`forecast_reply_time`,aib.`actual_reply_time`))-3),"") AS stipulatedOften,
IFNULL(LEFT(TIMEDIFF(aib.`actual_reply_time`,aib.`created_at`),LENGTH(TIMEDIFF(aib.`actual_reply_time`,aib.`created_at`))-3),"") AS actualOften,