You could use the UNIX_TIMESTAMP() function to easily determine
the difference in seconds between the two dates.

select UNIX_TIMESTAMP( Datetime_A ) ...

and the do the time_a - time_b thing. there might be a simple query that
will work as well, but I don't know the mysql date queries that good :)


.. Atle

On Tue, 20 Feb 2001, Duncan Hudson wrote:

> I have a table that contains two datetime columns, and I need to determine
> the time between the two dates.  So, what I've been doing is just
> subtracting what I know is the later date from the earlier date.  But that's
> obviously not the way to do it as my results don't relate to anything.
> Here's what my data looks like:
> 
> Datetime_A             Datetime_B            (Datetime_A - Datetime_B)
> 2001-02-20 14:09:38    2001-02-20 14:20:43   18.416666666667
> 2001-02-20 14:14:45    2001-02-20 14:30:35   26.5
> 2001-02-20 14:22:03    2001-02-20 14:28:14   10.183333333333
> 
> The differences should be 11 minutes 5 seconds, 15 minutes 50 seconds and 6
> minutes 11 seconds respectively - but that's not what I'm getting.  As I'm
> obviously doing this wrong, what is the correct means of determining the
> time difference between two datetime fields?  Thanks in advance,
> 
> 
> Dunc.
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to