文档章节

MYSQL 日期函数 Date and Time Functions

_liucui_
 _liucui_
发布于 2019/01/22 17:57
字数 487
阅读 28
收藏 0

精选30+云产品,助力企业轻松上云!>>>

 

Table 12.13 Date and Time Functions

Name

Description

ADDDATE()

Add time values (intervals) to a date value

ADDTIME()

Add time

CONVERT_TZ()

Convert from one time zone to another

CURDATE()

Return the current date

CURRENT_DATE()CURRENT_DATE

Synonyms for CURDATE()

CURRENT_TIME()CURRENT_TIME

Synonyms for CURTIME()

CURRENT_TIMESTAMP()CURRENT_TIMESTAMP

Synonyms for NOW()

CURTIME()

Return the current time

DATE()

Extract the date part of a date or datetime expression

DATE_ADD()

Add time values (intervals) to a date value

DATE_FORMAT()

Format date as specified

DATE_SUB()

Subtract a time value (interval) from a date

DATEDIFF()

Subtract two dates

DAY()

Synonym for DAYOFMONTH()

DAYNAME()

Return the name of the weekday

DAYOFMONTH()

Return the day of the month (0-31)

DAYOFWEEK()

Return the weekday index of the argument

DAYOFYEAR()

Return the day of the year (1-366)

EXTRACT()

Extract part of a date

FROM_DAYS()

Convert a day number to a date

FROM_UNIXTIME()

Format Unix timestamp as a date

GET_FORMAT()

Return a date format string

HOUR()

Extract the hour

LAST_DAY

Return the last day of the month for the argument

LOCALTIME()LOCALTIME

Synonym for NOW()

LOCALTIMESTAMPLOCALTIMESTAMP()

Synonym for NOW()

MAKEDATE()

Create a date from the year and day of year

MAKETIME()

Create time from hour, minute, second

MICROSECOND()

Return the microseconds from argument

MINUTE()

Return the minute from the argument

MONTH()

Return the month from the date passed

MONTHNAME()

Return the name of the month

NOW()

Return the current date and time

PERIOD_ADD()

Add a period to a year-month

PERIOD_DIFF()

Return the number of months between periods

QUARTER()

Return the quarter from a date argument

SEC_TO_TIME()

Converts seconds to 'HH:MM:SS' format

SECOND()

Return the second (0-59)

STR_TO_DATE()

Convert a string to a date

SUBDATE()

Synonym for DATE_SUB() when invoked with three arguments

SUBTIME()

Subtract times

SYSDATE()

Return the time at which the function executes

TIME()

Extract the time portion of the expression passed

TIME_FORMAT()

Format as time

TIME_TO_SEC()

Return the argument converted to seconds

TIMEDIFF()

Subtract time

TIMESTAMP()

With a single argument, this function returns the date or datetime expression; with two arguments, the sum of the arguments

TIMESTAMPADD()

Add an interval to a datetime expression

TIMESTAMPDIFF()

Subtract an interval from a datetime expression

TO_DAYS()

Return the date argument converted to days

TO_SECONDS()

Return the date or datetime argument converted to seconds since Year 0

UNIX_TIMESTAMP()

Return a Unix timestamp

UTC_DATE()

Return the current UTC date

UTC_TIME()

Return the current UTC time

UTC_TIMESTAMP()

Return the current UTC date and time

WEEK()

Return the week number

WEEKDAY()

Return the weekday index

WEEKOFYEAR()

Return the calendar week of the date (1-53)

YEAR()

Return the year

YEARWEEK()

Return the year and week

 

 

摘自官方文档 https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

 

 

 

 

 

 

 

 

_liucui_
粉丝 16
博文 133
码字总数 52730
作品 0
秦皇岛
私信 提问
加载中
请先登录后再评论。
mysql日期转换与计算函数

MySQL 获得当前日期时间 函数 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+| now() |+---------------------+| 2008-08-08 22:20:46 |+-----......

孟飞阳
2016/10/09
53
0
MySQL 获得当前日期时间 函数

https://www.cnblogs.com/ggjucheng/p/3352280.html 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+| now() |+---------------------+| 2008-......

osc_q4xkkmlj
2019/03/09
2
0
MySQL:日期函数、时间函数总结

MySQL 获得当前日期时间 函数 查询昨天,时间拼接 select concat(DATEFORMAT(dateadd(now(), interval -1 day),'%Y-%d-%d')," 23:59:59"); select DATEFORMAT(dateadd(now(), interval -2 da......

osc_2r66rowx
2018/06/20
5
0
MySQL 获得当前日期时间 函数

获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+| now() |+---------------------+| 2008-08-08 22:20:46 |+---------------------+ 获得当前日......

豆花饭烧土豆
2016/08/27
16
0
MySQL 获得当前日期时间 函数

MySQL 获得当前日期时间 函数 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+| now() |+---------------------+| 2008-08-08 22:20:46 |+-----......

osc_v8kogne9
2018/04/19
3
0

没有更多内容

加载失败,请刷新页面

加载更多

设计模式(6) 适配器模式

结构型模式 适配器模式 类适配器和对象适配器 结构型模式 结构型模式的重点在于如何通过灵活的体系组织不同的对象,并在此基础上完成更为复杂的类型(或者类型系统),而参与组合的各类型之间...

zhixin9001
37分钟前
15
0
《Kubernetes设计与实现》DaemonSet概述

TODO

恋恋美食
42分钟前
18
0
在打印预览模式下使用Chrome的Element Inspector? - Using Chrome's Element Inspector in Print Preview Mode?

问题: I am working on developing a website and need to work on the print view. 我正在开发一个网站,需要处理打印视图。 Typically when I have layout issues I use Chrome's Element......

javail
46分钟前
22
0
性能测试神器 wrk 使用教程

原文连接:https://blog.fengjx.com/wrk/ wrk 是一个类似 ab(apache bench)、jmeter 的压力测试工具,底层基于 epoll 和 kqueue 实现,能充分利用服务器 cpu 资源,降低测试工具本身性能开销...

ws-小铁匠
55分钟前
18
0
Pandas 秘籍·翻译完成

协议:CC BY-NC-SA 4.0 欢迎任何人参与和完善:一个人可以走的很快,但是一群人却可以走的更远。 在线阅读 ApacheCN 面试求职交流群 724187166 ApacheCN 学习资源 目录 Pandas 秘籍 零、前言...

布客飞龙
今天
24
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部