跳转到主要内容

日期时间函数

用于日期运算、格式化、解析、字段提取和读取时钟。

用于日期运算、格式化、解析、字段提取和读取时钟。

adddate

addtime

convert_tz

curdate

对象签名用途源码定义
mysql.curdate() → date返回当前日期。SQL

curtime

对象签名用途源码定义
mysql.curtime() → time without time zone返回当前时间。SQL
mysql.curtime(prec integer) → time without time zone返回当前时间。SQL

date

对象签名用途源码定义
mysql.date(numeric) → date提取日期部分或将输入解析为日期。SQL
pg_catalog.date(text) → date提取日期部分或将输入解析为日期。SQL

date_add

对象签名用途源码定义
mysql.date_add(date, interval) → date为日期加上天数或时间间隔。SQL
mysql.date_add(numeric, interval) → timestamp without time zone为日期加上天数或时间间隔。SQL
mysql.date_add(text, interval) → timestamp without time zone为日期加上天数或时间间隔。SQL
mysql.date_add(timestamp without time zone, interval) → timestamp without time zone为日期加上天数或时间间隔。SQL

date_format

对象签名用途源码定义
mysql.date_format(text, text) → text用 MySQL 百分号格式符格式化日期。SQL
mysql.date_format(timestamp with time zone, text) → text用 MySQL 百分号格式符格式化日期。SQL

date_sub

对象签名用途源码定义
mysql.date_sub(date, interval) → date从日期中减去天数或时间间隔。SQL
mysql.date_sub(numeric, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.date_sub(text, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.date_sub(timestamp without time zone, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL

datediff

对象签名用途源码定义
mysql.datediff(date, date) → integer计算两个日期相差的天数。SQL
mysql.datediff(numeric, numeric) → integer计算两个日期相差的天数。SQL
mysql.datediff(numeric, text) → integer计算两个日期相差的天数。SQL
mysql.datediff(text, numeric) → integer计算两个日期相差的天数。SQL
mysql.datediff(text, text) → integer计算两个日期相差的天数。SQL
mysql.datediff(text, timestamp without time zone) → integer计算两个日期相差的天数。SQL
mysql.datediff(timestamp without time zone, text) → integer计算两个日期相差的天数。SQL
mysql.datediff(timestamp without time zone, timestamp without time zone) → integer计算两个日期相差的天数。SQL

day

对象签名用途源码定义
mysql.day(numeric) → integer返回当月第几日。SQL
mysql.day(text) → integer返回当月第几日。SQL
mysql.day(timestamp without time zone) → integer返回当月第几日。SQL

dayname

对象签名用途源码定义
mysql.dayname(numeric) → text返回星期名称。SQL
mysql.dayname(text) → text返回星期名称。SQL
mysql.dayname(timestamp without time zone) → text返回星期名称。SQL

dayofmonth

对象签名用途源码定义
mysql.dayofmonth(numeric) → integer返回当月第几日。SQL
mysql.dayofmonth(text) → integer返回当月第几日。SQL
mysql.dayofmonth(timestamp without time zone) → integer返回当月第几日。SQL

dayofweek

对象签名用途源码定义
mysql.dayofweek(numeric) → integer返回星期编号,周日为 1。SQL
mysql.dayofweek(text) → integer返回星期编号,周日为 1。SQL
mysql.dayofweek(timestamp without time zone) → integer返回星期编号,周日为 1。SQL

dayofyear

对象签名用途源码定义
mysql.dayofyear(numeric) → integer返回当年的第几天。SQL
mysql.dayofyear(text) → integer返回当年的第几天。SQL
mysql.dayofyear(timestamp without time zone) → integer返回当年的第几天。SQL

extract

对象签名用途源码定义
mysql."extract"(text, text) → numeric提取指定的日期或时间字段。SQL
mysql."extract"(text, time without time zone) → numeric提取指定的日期或时间字段。SQL · C
mysql."extract"(text, timestamp without time zone) → numeric提取指定的日期或时间字段。SQL · C

from_days

对象签名用途源码定义
mysql.from_days(integer) → date将 MySQL 日序号转换为日期。SQL

from_unixtime

对象签名用途源码定义
mysql.from_unixtime(double precision) → timestamp without time zone将 Unix 时间转换为日期时间值或格式化字符串。SQL
mysql.from_unixtime(double precision, text) → text将 Unix 时间转换为日期时间值或格式化字符串。SQL

hour

last_day

对象签名用途源码定义
mysql.last_day(date) → date返回当月最后一天。SQL
mysql.last_day(numeric) → date返回当月最后一天。SQL
mysql.last_day(text) → date返回当月最后一天。SQL
mysql.last_day(timestamp with time zone) → date返回当月最后一天。SQL
mysql.last_day(timestamp without time zone) → date返回当月最后一天。SQL

makedate

对象签名用途源码定义
mysql.makedate(integer, integer) → date按年份和年内日序号生成日期。SQL

maketime

对象签名用途源码定义
mysql.maketime(integer, integer, numeric) → time without time zone用时、分、秒生成时间值。SQL

microsecond

minute

month

对象签名用途源码定义
mysql.month(numeric) → integer返回月份编号。SQL
mysql.month(text) → integer返回月份编号。SQL
mysql.month(timestamp without time zone) → integer返回月份编号。SQL

monthname

对象签名用途源码定义
mysql.monthname(numeric) → text返回月份名称。SQL
mysql.monthname(text) → text返回月份名称。SQL
mysql.monthname(timestamp without time zone) → text返回月份名称。SQL

now

对象签名用途源码定义
mysql.now() → timestamp without time zone返回当前事务的时间戳。SQL
mysql.now(prec integer) → timestamp without time zone返回当前事务的时间戳。SQL

period_add

对象签名用途源码定义
mysql.period_add(integer, integer) → text给年月值加上指定月数。SQL

period_diff

对象签名用途源码定义
mysql.period_diff(integer, integer) → integer按月计算两个年月值之差。SQL

quarter

对象签名用途源码定义
mysql.quarter(date) → integer返回季度编号。SQL
mysql.quarter(numeric) → integer返回季度编号。SQL
mysql.quarter(text) → integer返回季度编号。SQL
mysql.quarter(timestamp without time zone) → integer返回季度编号。SQL

sec_to_time

对象签名用途源码定义
mysql.sec_to_time(bigint) → time without time zone将秒数转换为时间值。SQL

second

str_to_date

对象签名用途源码定义
mysql.str_to_date(text, text) → timestamp without time zone按 MySQL 格式串解析日期或时间。SQL

subdate

对象签名用途源码定义
mysql.subdate(date, integer) → date从日期中减去天数或时间间隔。SQL
mysql.subdate(date, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(numeric, integer) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(numeric, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(text, integer) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(text, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(timestamp without time zone, integer) → timestamp without time zone从日期中减去天数或时间间隔。SQL
mysql.subdate(timestamp without time zone, interval) → timestamp without time zone从日期中减去天数或时间间隔。SQL

subtime

sysdate

对象签名用途源码定义
mysql.sysdate() → timestamp without time zone返回函数执行时的时钟时间。SQL
mysql.sysdate(prec integer) → timestamp without time zone返回函数执行时的时钟时间。SQL

time_format

对象签名用途源码定义
mysql.time_format(time without time zone, text) → text格式化时间值。SQL

time_to_sec

对象签名用途源码定义
mysql.time_to_sec(text) → bigint将时间值换算为秒数。SQL
mysql.time_to_sec(time without time zone) → bigint将时间值换算为秒数。SQL
mysql.time_to_sec(timestamp without time zone) → bigint将时间值换算为秒数。SQL

timediff

timestamp

对象签名用途源码定义
mysql."timestamp"(text, text) → timestamp without time zone根据输入的日期和时间构造时间戳。SQL

timestampadd

对象签名用途源码定义
mysql.timestampadd(text, integer, timestamp without time zone) → timestamp without time zone按指定时间单位增加给定数量。SQL

timestampdiff

to_days

对象签名用途源码定义
mysql.to_days(date) → integer将日期换算为 MySQL 日序号。SQL
mysql.to_days(text) → integer将日期换算为 MySQL 日序号。SQL
mysql.to_days(timestamp without time zone) → integer将日期换算为 MySQL 日序号。SQL

unix_timestamp

对象签名用途源码定义
mysql.unix_timestamp() → bigint返回自 Unix 纪元起的秒数。SQL
mysql.unix_timestamp(numeric) → numeric返回自 Unix 纪元起的秒数。SQL
mysql.unix_timestamp(text) → numeric返回自 Unix 纪元起的秒数。SQL
mysql.unix_timestamp(timestamp without time zone) → numeric返回自 Unix 纪元起的秒数。SQL

utc_date

对象签名用途源码定义
mysql.utc_date() → date返回 UTC 当前日期。SQL

utc_time

对象签名用途源码定义
mysql.utc_time() → time without time zone返回 UTC 当前时间。SQL
mysql.utc_time(prec integer) → time without time zone返回 UTC 当前时间。SQL

utc_timestamp

对象签名用途源码定义
mysql.utc_timestamp() → timestamp without time zone返回当前 UTC 时间戳。SQL
mysql.utc_timestamp(prec integer) → timestamp without time zone返回当前 UTC 时间戳。SQL

week

对象签名用途源码定义
mysql.week(numeric) → integer按周编号模式返回周数。SQL
mysql.week(numeric, integer) → integer按周编号模式返回周数。SQL
mysql.week(text) → integer按周编号模式返回周数。SQL
mysql.week(text, integer) → integer按周编号模式返回周数。SQL
mysql.week(timestamp without time zone) → integer按周编号模式返回周数。SQL
mysql.week(timestamp without time zone, integer) → integer按周编号模式返回周数。SQL

weekday

对象签名用途源码定义
mysql.weekday(numeric) → integer返回星期编号,周一为 0。SQL
mysql.weekday(text) → integer返回星期编号,周一为 0。SQL
mysql.weekday(timestamp without time zone) → integer返回星期编号,周一为 0。SQL

weekofyear

对象签名用途源码定义
mysql.weekofyear(numeric) → integer返回当年的第几周。SQL
mysql.weekofyear(text) → integer返回当年的第几周。SQL
mysql.weekofyear(timestamp without time zone) → integer返回当年的第几周。SQL

year

yearweek

对象签名用途源码定义
mysql.yearweek(numeric) → integer返回周年和周数组合值。SQL
mysql.yearweek(qdate numeric, mode integer) → integer返回周年和周数组合值。SQL
mysql.yearweek(qdate text, mode integer) → integer返回周年和周数组合值。SQL
mysql.yearweek(qdate timestamp without time zone, mode integer) → integer返回周年和周数组合值。SQL
mysql.yearweek(text) → integer返回周年和周数组合值。SQL
mysql.yearweek(timestamp without time zone) → integer返回周年和周数组合值。SQL