Why donĀ“t you try
select TO_DAYS(end_date)-TO_DAYS(start_date) as duration : this will return
the difference in days
if you need mor accuracy i.e. difference in hours, you should word on a
TIMESTAMP 14 instead of date ; this data type holds up to seconds and is
mathematically easy to operate ...
i hope it helps

----- Original Message -----
From: "Ken Kinder" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 15, 2001 8:32 PM
Subject: Subtracting Dates


> The date addition and subtraction functions in mysql don't seem to quiet
do
> this. I was wondering if anyone know a way I could do this in the query:
>
> Say you have two fields, start_time, and end_time, representing the start
and
> end of a period of time. Both are datetime datatypes. What I want is the
> logical equivalent of:
>
> select end_time - start_time as duration from ....
>
> I want the difference between those two, such that it would say "0 days, 4
> hours" or something.
>
> ---------------------------------------------------------------------
> 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