• MySQL时间类型1


    (1)当前日期类型

    mysql> create table thetime(t date);
    Query OK, 0 rows affected (0.09 sec)

    mysql> insert into thetime values(now());
    Query OK, 1 row affected, 1 warning (0.06 sec)

    mysql> select * from thetime;
    +------------+
    | t          |
    +------------+
    | 2013-04-28 |
    +------------+
    1 row in set (0.00 sec)

    mysql>

    (2)当前时间类型

    mysql> create table thetime(t time);
    Query OK, 0 rows affected (0.11 sec)

    mysql> insert into thetime values(now());
    Query OK, 1 row affected (0.30 sec)

    mysql> select * from thetime;
    +----------+
    | t        |
    +----------+
    | 00:56:30 |
    +----------+
    1 row in set (0.00 sec)

    mysql>

    (3)当前日期和时间类型

    mysql> create table thetime(t datetime);
    Query OK, 0 rows affected (0.11 sec)

    mysql> insert into thetime values(now());
    Query OK, 1 row affected (0.09 sec)

    mysql> select * from thetime;
    +---------------------+
    | t                   |
    +---------------------+
    | 2013-04-28 00:56:54 |
    +---------------------+
    1 row in set (0.00 sec)

    mysql>

    (4)获取当前日期和时间

     mysql> select now();
    +---------------------+
    | now()               |
    +---------------------+
    | 2013-04-28 01:02:58 |
    +---------------------+
    1 row in set (0.00 sec)

    mysql>

    总结:datetime(当前日期和时间) = date(当前日期) + time(当前时间)。

  • 相关阅读:
    pxc5.7配置安装
    在SQL中 给字符串补0方法
    python中字符串连接的四种方式
    python中math模块常用的方法整理
    python 字符串比较
    sql去重;同一条数据出现多条取一条的sql语句
    给一行添加数据库不存在的自然数顺序编号
    jvisualvm下载
    sql截取字符串后面四位
    idea破解更新
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3060260.html
Copyright © 2020-2023  润新知