zoukankan      html  css  js  c++  java
  • 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(当前时间)。

  • 相关阅读:
    C 语言 静态库和动态库的创建和应用
    C++ 中英文术语对照
    下午
    [转]内核 do_fork 函数源代码浅析
    关于C#反射机制,自己写的
    获取字符串中数字
    关于C#反射机制,来源于网络
    关于 Nhinernate 的one to one(转载)
    鼠标坐标的记录
    关于C#中hibernate.cfg.xml动态加载问题
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3060260.html
Copyright © 2011-2022 走看看