2个日期 如何进行比较 在mysql
我用 select * from a where to_day(thisdaty) >to_day(now());
总是 失败 , 结果 2009-10-1的日期都出来了 按照道理不因该处理啊才对或来用day(日期)》day(now())还是失败
直接写where createdDate > now(); 还是失败 不知奥如何进行比较2个日期 必须有 now() 或者curdate 我程序里用到的是这2个 和当前日期比较的 。不知道哦啊有没有sqlserver的恶diff日期比较函数来做这个 ??
我用 select * from a where to_day(thisdaty) >to_day(now());
总是 失败 , 结果 2009-10-1的日期都出来了 按照道理不因该处理啊才对或来用day(日期)》day(now())还是失败
直接写where createdDate > now(); 还是失败 不知奥如何进行比较2个日期 必须有 now() 或者curdate 我程序里用到的是这2个 和当前日期比较的 。不知道哦啊有没有sqlserver的恶diff日期比较函数来做这个 ??
+-----------------+
| now()>curdate() |
+-----------------+
| 1 |
+-----------------+
1 row in set (0.38 sec)mysql>
因为thisday<now().
请看mysql> select curdate() as thisday;
+------------+
| thisday |
+------------+
| 2010-02-05 |
+------------+
1 row in set (0.00 sec)mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2010-02-05 09:05:45 |
+---------------------+
1 row in set (0.00 sec)
这样的比较,前者是不可能大于后者的。
前者默认是2010-02-05 00:00:00