程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql now() Incorrect datetime value for column

mysql now() Incorrect datetime value for column

編輯:MySQL綜合教程

mysql> select now(); select now() -10;
+---------------------+
| now()               |
+---------------------+
| 2009-09-25 21:07:20 |
+---------------------+
1 row in set (0.00 sec)

+-----------------------+
| now() -10             |
+-----------------------+
| 20090925210710.000000 |
+-----------------------+
1 row in set (0.00 sec)

sometime it works, but sometime doesnt for
" mysql now() Incorrect datetime value for column "

There's an insidious problem doing simple maths using now() ... subtraction of seconds and minutes etc are based on 100 seconds in a minute, and 100 minutes in an hour ...

so, you need to be do something more like:
select now(); select now() -INTERVAL 10 SECOND;

and that's how to solver the problem.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved