Surpassing MySQL's TIME value limit of 838:59:59

前端 未结 6 549
南旧
南旧 2020-12-01 14:54

The title might be a bit confusing so allow me to explain. I\'m using a table to record my work logs. Every day I\'ll create an entry stating from what time to what time I h

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 15:36

    First calculating the days difference then multiply it with 24*60*60 to convert it into seconds then add to it time_to_sec value result

    DATEDIFF(start_date,end_date)*24*60*60 + TIME_TO_SEC(TIMEDIFF(TIME(start_date),TIME(end_date))) 
    AS sec_diff
    

    For more details check codebucket- Surpassing time_to_sec() function maximum limit

提交回复
热议问题