Brian Erickson wrote:
We have a table that has two datetime fields (start_time and
end_time). We'd like to be able to calculate the number of seconds
between these two fields in a query. However, a simple "end_time -
start_time" does not yield a correct result.

SELECT start_time, end_time, end_time - start_time FROM
mailings_sendstats order by start_time desc;
[...]
So my question is, how can I fix this? I know there are several
date/time functions that I could probably use, but they were not
introduced until version 4.1 and I am stuck with version 3.23.

There are lots of date/time functions available in version 3.23, for example unix_timestamp():


SELECT start_time, end_time,
  unix_timestamp(end_time) - unix_timestamp(start_time) AS seconds
FROM mailings_sendstats order by start_time desc;

--
Roger


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to