Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
Description
Using extract to get number of hours from a time_diff function produces incorrect results when number of hours is greater than 23.
Here's the details...
SET @prev_ts = '2017-11-30 11:00:00'; |
SELECT NOW() |
, TIMEDIFF(NOW(),@prev_ts)
|
, TIME_FORMAT(TIMEDIFF(NOW(),@prev_ts), '%H') AS 'diff TIME_FORMAT' |
, EXTRACT(HOUR FROM TIMEDIFF(NOW(),@prev_ts)) AS 'diff EXTRACT ' |
;
|
/*
|
NOW() TIMEDIFF(NOW(),@prev_ts) diff TIME_FORMAT diff EXTRACT
|
2017-12-15 20:58:25 369:58:25 369 9
|
*/ |
SET @prev_ts = '2017-12-14 22:00:00'; |
SELECT NOW() |
, TIMEDIFF(NOW(),@prev_ts)
|
, TIME_FORMAT(TIMEDIFF(NOW(),@prev_ts), '%H') AS 'diff TIME_FORMAT' |
, EXTRACT(HOUR FROM TIMEDIFF(NOW(),@prev_ts)) AS 'diff EXTRACT ' |
;
|
/*
|
NOW() TIMEDIFF(NOW(),@prev_ts) diff TIME_FORMAT diff EXTRACT
|
2017-12-15 21:19:32 23:19:32 23 23
|
*/ |