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)
    

  • 相关阅读:
    (判断是否为弱联通分量) poj 2762
    (最大生成树) poj 1979
    (暴力) bzoj 2208
    (BFS) bzoj 1102
    (并查集) bzoj 1161
    (数学) bzoj 1800
    (博弈) bzoj 2460
    (dinic) poj 3469
    (双端队列优化的SPFA) bzoj 2100
    (判断负环) bzoj 2019
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351738.html
Copyright © 2011-2022 走看看