|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: # Seconds between two datetime fields
From: Roger Baklund (roger
charlott.no)
Date: Thu Mar 03 2005 - 19:15:41 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]