How to calculate the difference between two dates, in the format YYYY-MM-DD hh: mm: ss
and to get the result in seconds or milliseconds?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- sqlyog export query result as csv
OK it's not quite what the OP asked, but it's what I wanted to do :-)
You would simply do this:
So, you can use
TIMESTAMPDIFF
for your purpose.Or, you could use TIMEDIFF function
If you are working with DATE columns (or can cast them as date columns), try DATEDIFF() and then multiply by 24 hours, 60 min, 60 secs (since DATEDIFF returns diff in days). From MySQL:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
for example: