Bug #882 | Subtraction of DATETIME's doesn't work across midnight boundary | ||
---|---|---|---|
Submitted: | 21 Jul 2003 12:11 | Modified: | 21 Jul 2003 12:33 |
Reporter: | [ name withheld ] | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S1 (Critical) |
Version: | 4.0.13-0 | OS: | Linux (Red Hat Linux 9) |
Assigned to: | CPU Architecture: | Any |
[21 Jul 2003 12:11]
[ name withheld ]
[21 Jul 2003 12:33]
Indrek Siitan
MySQL does not support that kind of arithmetics on date fields directly. If you try mathematical functions, MySQL does the best to interpret the given values as numbers. In this case, what it does, is 20030720002131-20030719214618, which comes out to 787513. To yield the result you need, you can do: select start_time, stop_time, unix_timestamp(stop_time) - unix_timestamp(start_time) from party;
[21 Jul 2003 12:52]
[ name withheld ]
Thanks. That works.