Ronald Ramos wrote:

create table oras(
Name    VARCHAR(30),
TimeIn DATETIME,
TimeOut DATETIME,
Total   DATETIME
);

insert into oras values('Nhadie','2004-10-10 10:10:00','2004-11-11
12:12:00','TIMEDIFF(TimeIn,TImeOut)');

Hi,

Are those correct? Because the value on the Total field is 000-00-00
00:00:00.
I think there's something wrong. I'm using 4.0.


mysql> select * from oras; +--------+---------------------+---------------------+------------------ ---+ | Name | TimeIn | TimeOut | Total | +--------+---------------------+---------------------+------------------ ---+ | Nhadie | 2004-10-10 10:10:00 | 2004-11-11 12:12:00 | 0000-00-00 00:00:00 | +--------+---------------------+---------------------+------------------ ---+ 1 row in set (0.01 sec)

TIA

I would not use DATETIME column type for Total as it is dependable on the number of days in the month. Use INT and store the number of seconds instead. Then you can update the column using:


UPDATE oras SET Total = SELECT UNIX_TIMESTAMP(field1) - UNIX_TIMESTAMP(field2) [WHERE where_condition]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to