Re: Re: I think this is a mysql question
| From: | Marek Kilimajer | Date: | Thu, 12 Feb 2004 13:42:30 +0000 |
| Subject: | Re: Re: I think this is a mysql question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177519@lists.php.net to get a copy of this message | ||
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; +--------+---------------------+---------------------+------------------ ---+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(TimeIn) - UNIX_TIMESTAMP(TimeOut) [WHERE where_condition]| 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