Now() and time function bug??
Alright, I was messing around with some time functions in Mysql and ran acrossed a wierd bug. After I set starttime to now(), anytime I run another update query against the row starttime changes to a new value. Here is what I did when I noticed the bug.. Does anyone else have a problem doing this? I'm using (mysql Ver 11.18 Distrib 3.23.56, for slackware-linux (i386)) mysql select * from clientwork; +++---+--+++---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++---+---+ | 1 | 1 | 1 |1 | 20030617123435 | 20030617123435 | 95 | | +++---+--+++---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET totaltime=now()-starttime, stoptime=now() where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++---+---+ | 1 | 1 | 1 |1 | 20030617124037 | 20030617124037 | 602 | | +++---+--+++---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET totaltime=(now()-starttime), stoptime=(now()) where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++---+---+ | 1 | 1 | 1 |1 | 20030617124122 | 20030617124122 | 85 | | +++---+--+++---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET notes=This is my note where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++---+-+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++---+-+ | 1 | 1 | 1 |1 | 20030617124213 | 20030617124122 | 85 | This is my note | +++---+--+++---+-+ 1 row in set (0.01 sec) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Now() and time function bug??
You are absolutely correct.. I did set it to timestamp by mistake! -//Lucas On Tue, 17 Jun 2003, Jennifer Goodie wrote: After I set starttime to now(), anytime I run another update query against the row starttime changes to a new value. If starttime is the timestamp data type, and the first timestamp in the row, it will automatically update every time you update the row. This is not a bug, it is expected behavior. Read up on the timestamp data type (http://www.mysql.com/doc/en/DATETIME.html). If it is a type other than timestamp (you did not specify), then this could be a bug. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Now() and time function bug??
On 17 Jun 2003 at 14:05, Lucas Heuman wrote: After I set starttime to now(), anytime I run another update query against the row starttime changes to a new value. You don't give the structure of your table, but it appears that you're using a TIMESTAMP column, which has automatic updating by design: http://www.mysql.com/doc/en/DATETIME.html If you don't want automatic updating, perhaps you should use a DATETIME column instead. -- Keith C. Ivey [EMAIL PROTECTED] Tobacco Documents Online http://tobaccodocuments.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Now() and time function bug??
That's really odd. I've never experienced that problem, but I'm running the latest production release (4.0.13), so I perhaps it's been fixed between versions. Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Lucas Heuman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, 17 June, 2003 14:05 Subject: Now() and time function bug?? Alright, I was messing around with some time functions in Mysql and ran acrossed a wierd bug. After I set starttime to now(), anytime I run another update query against the row starttime changes to a new value. Here is what I did when I noticed the bug.. Does anyone else have a problem doing this? I'm using (mysql Ver 11.18 Distrib 3.23.56, for slackware-linux (i386)) mysql select * from clientwork; +++---+--+++ ---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++ ---+---+ | 1 | 1 | 1 |1 | 20030617123435 | 20030617123435 | 95 | | +++---+--+++ ---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET totaltime=now()-starttime, stoptime=now() where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++ ---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++ ---+---+ | 1 | 1 | 1 |1 | 20030617124037 | 20030617124037 | 602 | | +++---+--+++ ---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET totaltime=(now()-starttime), stoptime=(now()) where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++ ---+---+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++ ---+---+ | 1 | 1 | 1 |1 | 20030617124122 | 20030617124122 | 85 | | +++---+--+++ ---+---+ 1 row in set (0.00 sec) mysql UPDATE clientwork SET notes=This is my note where id=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from clientwork; +++---+--+++ ---+-+ | id | active | companyid | worktype | starttime | stoptime | totaltime | notes | +++---+--+++ ---+-+ | 1 | 1 | 1 |1 | 20030617124213 | 20030617124122 | 85 | This is my note | +++---+--+++ ---+-+ 1 row in set (0.01 sec) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Now() and time function bug??
After I set starttime to now(), anytime I run another update query against the row starttime changes to a new value. If starttime is the timestamp data type, and the first timestamp in the row, it will automatically update every time you update the row. This is not a bug, it is expected behavior. Read up on the timestamp data type (http://www.mysql.com/doc/en/DATETIME.html). If it is a type other than timestamp (you did not specify), then this could be a bug. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]