海诗网 知识百科 mysql(mysql下载)

mysql(mysql下载)

mysql, mysql中的date函数是什么,如何使用?不知道小伙伴们今天来看看边肖的分享吧!

1.日期功能介绍:

MySQL数据库Date () date函数,用于查询MySQL数据库中的当前日期和时间。

2.用法:

获取当前时间:

MySQLselectcurrent_timestamp();

+---------------------+

|current_timestamp()|

+---------------------+

|2010-01-1821:24:37|

+---------------------+

1rowinset(0.00sec)

MySQLselectcurrent_date();

+----------------+

|current_date()|

+----------------+

|2010-01-18|

+----------------+

1rowinset(0.00sec)

MySQLselectcurrent_time();

+----------------+

|current_time()|

+----------------+

|21:24:46|

+----------------+

1rowinset(0.00sec)

mysql下载

Unix时间:

MySQLselectunix_timestamp();

+------------------+

|unix_timestamp()|

+------------------+

|1263821184|

+------------------+

1rowinset(0.00sec)

MySQLselectfrom_unixtime(1263821182);

+---------------------------+

|from_unixtime(1263821182)|

+---------------------------+

|2010-01-1821:26:22|

+---------------------------+

1rowinset(0.00sec)

大约时间:

MySQLselectdate_add(current_timestamp,interval1day);

+---------------------------------------------+

|date_add(current_timestamp,interval1day)|

+---------------------------------------------+

|2010-01-1921:27:53|

+---------------------------------------------+

1rowinset(0.00sec)

MySQLselectdate_add(current_time,interval1day);

+----------------------------------------+

|date_add(current_time,interval1day)|

+----------------------------------------+

|NULL|

+----------------------------------------+

1rowinset,1warning(0.00sec)

MySQLselectdate_add(current_date,interval1day);

+----------------------------------------+

|date_add(current_date,interval1day)|

+----------------------------------------+

|2010-01-19|

+----------------------------------------+

1rowinset(0.00sec)

MySQLselectdate_sub(current_timestamp,interval1day);

+---------------------------------------------+

|date_sub(current_timestamp,interval1day)|

+---------------------------------------------+

|2010-01-1721:28:41|

+---------------------------------------------+

1rowinset(0.00sec)

MySQLselectdate_sub(current_date,interval1day);

+----------------------------------------+

|date_sub(current_date,interval1day)|

+----------------------------------------+

|2010-01-17|

+----------------------------------------+

1rowinset(0.00sec)

MySQLselectdate_sub(current_time,interval1day);

+----------------------------------------+

|date_sub(current_time,interval1day)|

+----------------------------------------+

|NULL|

+----------------------------------------+

1rowinset,1warning(0.00sec)

mysql下载

时间间隔:

MySQLselectdatediff(2010-01-18,2010-01-17);

+-------------------------------------+

|datediff(2010-01-18,2010-01-17)|

+-------------------------------------+

|1|

+-------------------------------------+

1rowinset(0.00sec)

MySQLselecttimediff(2010-01-1812:00,2010-01-1711:00);

+-------------------------------------------------+

|timediff(2010-01-1812:00,2010-01-1711:00)|

+-------------------------------------------------+

|25:00:00|

+-------------------------------------------------+

1rowinset(0.00sec)

时间转换:

MySQLselecttime_to_sec(25:00:00);

+-------------------------+

|time_to_sec(25:00:00)|

+-------------------------+

|90000|

+-------------------------+

1rowinset(0.00sec)

MySQLselectsec_to_time(90000);

+--------------------+

|sec_to_time(90000)|

+--------------------+

|25:00:00|

+--------------------+

1rowinset(0.00sec)

mysql,以上就是本文为您收集整理的mysql最新内容,希望能帮到您!更多相关内容欢迎关注。

本文来自网络,不代表海诗网立场,转载请注明出处:https://m.hallse.com/n/169315.html
发表回复