What is the behavior for the minus operator between two datetimes in MySQL? -
the difference between datetimes number of seconds between them. seems work if datetimes occur in same hour.
why this?
mysql> update events set created_at = "2011-04-13 15:59:59", fulfilled_at ="2011-04-13 16:00:00" id = 1; mysql> select fulfilled_at - created_at, timediff(fulfilled_at, created_at) events id = 1; +---------------------------+------------------------------------+ | fulfilled_at - created_at | timediff(fulfilled_at, created_at) | +---------------------------+------------------------------------+ | 4041.000000 | 00:00:01 | +---------------------------+------------------------------------+ i know should using timediff, i'm curious why i'm seeing or if it's documented somewhere.
mysql converting strings numbers best can, can mathematical operation on them. in case, stripping out of non numerical colons, dashes , spaces.
try this:
select (20110413155959 - 20110413160000) dates; your dates, without stuff stops them being numbers - result -4041
Comments
Post a Comment