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

Have a look at timestampdiff which doesn’t have the TIME limitation.
I.e. something like (untested):

SELECT CONCAT(
        TIMESTAMPDIFF(HOURS, entry_end_time, entry_start_time), 
        ":",
        MOD(TIMESTAMPDIFF(MINUTES, entry_end_time, entry_start_time),60)
      )
AS total FROM entry 
WHERE entry_date BETWEEN '2012-01-01' AND '2012-12-31' AND user_id = 3

The concats not ideal, I’m sure there will be a more elegant solution.

Leave a Comment