TIMEDIFF

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

TIMEDIFF

Post by winsonlee »

$sql = "SELECT in_date, in_time, out_date, out_time, TIMEDIFF(out_time,in_time) FROM XXX";

Just wondering for the TIMEDIFF funciton, I can only put in one column name for time in and out or I can put in the date as well ???

i tried something like TIMEDIFF(out_date.out_time,in_date.in_time)
it doesnt seems to be working

The following data is in my table
in_date in_time out_date out_time
10/11/06 00:02 10/11/06 00:02
10/11/06 00:02 10/11/06 00:03
15/11/06 15:41 16/11/06 09:34
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html wrote:TIMEDIFF() returns expr1 – expr2 expressed as a time value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.
So don't use separate fields for date and time, use one single DATETIME field
in_date + in_time => login
out_date + out_time => logout
Post Reply