zoukankan      html  css  js  c++  java
  • mysql 日期型比较操作

    mysql> create table t10(id int,start_dt date);
    Query OK, 0 rows affected (0.89 sec)
    
    mysql> desc t10
        -> ;
    +----------+---------+------+-----+---------+-------+
    | Field    | Type    | Null | Key | Default | Extra |
    +----------+---------+------+-----+---------+-------+
    | id       | int(11) | YES  |     | NULL    |       |
    | start_dt | date    | YES  |     | NULL    |       |
    +----------+---------+------+-----+---------+-------+
    2 rows in set (0.04 sec)
    
    mysql> insert into t10 values(1,2010-01-01);
    ERROR 1292 (22007): Incorrect date value: '2008' for column 'start_dt' at row 1
    mysql> insert into t10 values(1,20100101);
    Query OK, 1 row affected (0.05 sec)
    
    mysql> insert into t10 values(2,20100201);
    Query OK, 1 row affected (0.00 sec)
    
    
    insert into t10 values(3,20100301);
    insert into t10 values(3,20100301);
    insert into t10 values(4,20100401);
    insert into t10 values(5,20100501);
    insert into t10 values(6,20100601);
    insert into t10 values(7,20100701);
    insert into t10 values(8,20100801);
    insert into t10 values(9,20100901);
    
    
    mysql>  select * from t10 where start_dt >20100201 and start_dt<20100601;
    +------+------------+
    | id   | start_dt   |
    +------+------------+
    |    3 | 2010-03-01 |
    |    3 | 2010-03-01 |
    |    4 | 2010-04-01 |
    |    5 | 2010-05-01 |
    +------+------------+
    4 rows in set (0.00 sec)
    

  • 相关阅读:
    让所有IE支持HTML5的解决方案
    MVC3实现多个按钮提交
    水平垂直居中
    模块化开发之sea.js实现原理总结
    express常见获取参数的方法
    使用nodemon提高nodejs调试效率
    Vue2 实践揭秘 错误列表
    全局安装 Vue cli3 和 继续使用 Vue-cli2.x
    使用VUECLI3
    npm ERR! code Z_BUF_ERROR
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351738.html
Copyright © 2011-2022 走看看