1. 程式人生 > >mysql bigint型別時間做運算

mysql bigint型別時間做運算

bigint型別時間轉date型別:
DATE_FORMAT(FROM_UNIXTIME(start_time/1000),’%Y-%m-%d %H:%i:%S’) as start_time,
DATE_FORMAT(FROM_UNIXTIME(end_time/1000),’%Y-%m-%d %H:%i:%S’) as end_time,
bigint型別時間運算精確到毫秒(單位/分):
convert(IFNULL(TIMESTAMPDIFF(SECOND,DATE_FORMAT(FROM_UNIXTIME(start_time/1000),’%Y-%m-%d %H:%i:%S’),
DATE_FORMAT(FROM_UNIXTIME(end_time/1000),’%Y-%m-%d %H:%i:%S’))/60,0),decimal(12,2)) ,
結束時間減去開始時間運算:
convert(IFNULL(TIMESTAMPDIFF(SECOND,DATE_FORMAT(FROM_UNIXTIME(b.start_time/1000),’%Y-%m-%d %H:%i:%S’)
,DATE_FORMAT(FROM_UNIXTIME(b.end_time/1000),’%Y-%m-%d %H:%i:%S’))/60,0),decimal(12,2)) convert_time