关于时间的模糊查询 mysql
- select * from tableName where fieldName like '2009-12-29%';
- select * from tableName where ( datediff ( fieldName , '2009-12-29' ) = 0 );
- select * from orders where tableName between '2009-12-10 24:00:00' and '2009-12-29 23:00:00';
- select * from tableName where year(fieldName)='2009' And month(fieldName)='12';
自研新方法:
由于时间类型实际上是浮点数类型,直接对时间类型进行数字加减不会报错,得到的仍是浮点数。这种方式是进行数值运算,应该效率最高把。
故有
当前整点小时的表示方式
NOW()-SECOND(NOW())-(MINUTE(NOW())*100)
此处评论已关闭