0

I'm just curious because most DBs I ever worked with, when tasked with SOMEDATE - ANOTHERDATE return the difference in days between the two dates

MySQL seems to return a number that is.. er.. I've no idea. Sometimes it's the seconds. Sometimes it's just garbage

2013-06-05 09:57:59 - 2013-06-05 09:57:33 = 26 and yes, 26 seconds is the correct difference between these two times

2013-06-03 00:23:07 - 2013-06-02 23:49:51 = 12789 but wait.. 12789 is 3.5 hours yet these times only differ by about half an hour

So what is MySQL actually doing under the hood when I give it two date types and tell it to minus one from the other? What is this number result representative of?

Caius Jard
  • 72,509
  • 5
  • 49
  • 80
  • 1
    http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_timestampdiff – Oliver Charlesworth Jun 05 '13 at 09:06
  • Thanks for the pointer, and it's certainly helpful in that it's the solution to the problem of making MySQL behave like other DBs but I can't see an answer to the question (which is effectively, what is this nonsense number emitted by MySQL when you ask it to subtract one date from another?) – Caius Jard Jun 05 '13 at 13:07

0 Answers0