I've created a function for mysql using phpmyadmin (that works fine). It calculates de diference between two dates in days, hours, minutes and seconds. The output could be one like this:
5d 16h 24m 56s
The mentioned function:
CREATE FUNCTION time_full(A DATETIME, B DATETIME) RETURNS VARCHAR(30)
BEGIN
RETURN CONCAT(FLOOR(HOUR(TIMEDIFF(A,B))/24),'d '
,MOD(HOUR(TIMEDIFF(A,B)),24), 'h '
,MINUTE(TIMEDIFF(A,B)),'m '
,SECOND(TIMEDIFF(A, B)),'s');
END
So after creating it and checking that works fine I decided to make it calculate a big gap of time between two dates, something like 2 months or so, but the biggest gap that it can calculates is:
34d 22h 59m 59s
Anyone knows why? (That's the big question)
I knew something was happening since with the query function:
SEC_TO_TIME(TIMESTAMPDIFF(SECOND, created, sol_provided)) AS timeDiff
I was having a trouble since the biggest gap in hours that it could calculate was something like 848 hours or so.
From the MySQL website (http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timediff)
The result returned by TIMEDIFF() is limited to the range allowed for TIME values
Then if you continue to the section on TIME, (http://dev.mysql.com/doc/refman/5.5/en/time.html)
TIME values may range from '-838:59:59' to '838:59:59'. The hours part may be so large because the TIME type can be used not only to represent a time of day (which must be less than 24 hours), but also elapsed time or a time interval between two events (which may be much greater than 24 hours, or even negative).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With