Quote:
|
Originally Posted by cancer10
Not sure if this is a bug or not.
|
i bet it isn't
Code:
CREATE TABLE test_timediff
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, start_datetime DATETIME
, end_datetime DATETIME
);
INSERT INTO test_timediff VALUES
( 1, '2009-02-13 23:00:00','2009-02-13 00:30:00' )
,( 2, '2009-02-14 23:00:00','2009-02-13 00:30:00' )
,( 3, '2009-02-13 23:00:00','2009-02-14 00:30:00' )
;
SELECT t.*
, TIMEDIFF(start_datetime,end_datetime) AS diff1
, TIMEDIFF(end_datetime,start_datetime) AS diff2
FROM test_timediff AS t
;
/* results:
id start_datetime end_datetime diff1 diff2
1 2009-02-13 23:00:00 2009-02-13 00:30:00 22:30:00 -22:30:00
2 2009-02-14 23:00:00 2009-02-13 00:30:00 46:30:00 -46:30:00
3 2009-02-13 23:00:00 2009-02-14 00:30:00 -01:30:00 01:30:00
*/
any questions?
