Bug #76202 | wrong time calculation | ||
---|---|---|---|
Submitted: | 6 Mar 2015 22:24 | Modified: | 7 Mar 2015 8:12 |
Reporter: | Albert Bonomo | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | XAMPP for Linux 5.5.19-0! | OS: | Linux |
Assigned to: | CPU Architecture: | Any | |
Tags: | time, timestamp |
[6 Mar 2015 22:24]
Albert Bonomo
[7 Mar 2015 8:12]
MySQL Verification Team
This is not a bug. You cannot just subtract dates, as mysql tries to treat them as numbers. You must use appropriate function. http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html Try this to see the result: drop table if exists t1; create table t1(a datetime); insert into t1 values(current_timestamp); select a from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1; do sleep(3); select current_timestamp-a,unix_timestamp()-unix_timestamp(a) from t1;