2 messages in com.mysql.lists.mysqlRe: Calculating time fields
FromSent OnAttachments
Todd Schacherl17 Aug 2002 16:23 
Paul DuBois17 Aug 2002 16:34 
Subject:Re: Calculating time fields
From:Paul DuBois (pa@snake.net)
Date:08/17/2002 04:34:42 PM
List:com.mysql.lists.mysql

At 16:23 -0700 8/17/02, Todd Schacherl wrote:

Hi Folks,

I have a MYSQL table with timeIn and a timeOut columns and I'm trying to figure out if I can calculate the difference within a SELECT statement. Both fields are type TIME (e.g., 00:00:00).

What units do you want the result in? To get the difference in seconds, use:

TIME_TO_SEC(timeOut) - TIME_TO_SEC(timeIn)

If you want the difference as a TIME, pass that result to SEC_TO_TIME().

Thanks,

One of the penalties for refusing to participate in politics is that you end up being governed by your inferiors. -Plato