# 日期时间函数

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

---

LLMS 索引： [llms.txt](/zh/llms.txt)

---

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

## adddate {#adddate}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-adddate-pg-catalog-date-integer-518d10b0" href="#mysql-adddate-pg-catalog-date-integer-518d10b0">`mysql.adddate(date, integer) → date`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L467-L473) |
| <a id="mysql-adddate-pg-catalog-date-interval-e20f7939" href="#mysql-adddate-pg-catalog-date-interval-e20f7939">`mysql.adddate(date, interval) → date`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L459-L465) |
| <a id="mysql-adddate-numeric-integer-a8e92c95" href="#mysql-adddate-numeric-integer-a8e92c95">`mysql.adddate(numeric, integer) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L499-L505) |
| <a id="mysql-adddate-numeric-interval-78debadb" href="#mysql-adddate-numeric-interval-78debadb">`mysql.adddate(numeric, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L491-L497) |
| <a id="mysql-adddate-pg-catalog-text-integer-2da6ad21" href="#mysql-adddate-pg-catalog-text-integer-2da6ad21">`mysql.adddate(text, integer) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L483-L489) |
| <a id="mysql-adddate-pg-catalog-text-interval-982db374" href="#mysql-adddate-pg-catalog-text-interval-982db374">`mysql.adddate(text, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L475-L481) |
| <a id="mysql-adddate-timestamp-without-time-zone-integer-2898acc2" href="#mysql-adddate-timestamp-without-time-zone-integer-2898acc2">`mysql.adddate(timestamp without time zone, integer) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L450-L456) |
| <a id="mysql-adddate-timestamp-without-time-zone-interval-64fc25cb" href="#mysql-adddate-timestamp-without-time-zone-interval-64fc25cb">`mysql.adddate(timestamp without time zone, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L442-L448) |

## addtime {#addtime}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-addtime-pg-catalog-text-double-precision-a6dd58a8" href="#mysql-addtime-pg-catalog-text-double-precision-a6dd58a8">`mysql.addtime(text, double precision) → text`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2103-L2111) |
| <a id="mysql-addtime-pg-catalog-text-pg-catalog-text-e168ba4b" href="#mysql-addtime-pg-catalog-text-pg-catalog-text-e168ba4b">`mysql.addtime(text, text) → text`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1733-L1737) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L204-L217) |
| <a id="mysql-addtime-pg-catalog-text-time-without-time-zone-945c6353" href="#mysql-addtime-pg-catalog-text-time-without-time-zone-945c6353">`mysql.addtime(text, time without time zone) → text`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1712-L1718) |
| <a id="mysql-addtime-time-without-time-zone-double-precision-1d9636f1" href="#mysql-addtime-time-without-time-zone-double-precision-1d9636f1">`mysql.addtime(time without time zone, double precision) → time without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2093-L2101) |
| <a id="mysql-addtime-time-without-time-zone-pg-catalog-text-8819b5f7" href="#mysql-addtime-time-without-time-zone-pg-catalog-text-8819b5f7">`mysql.addtime(time without time zone, text) → time without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1704-L1710) |
| <a id="mysql-addtime-time-without-time-zone-time-without-time-zone-22d32301" href="#mysql-addtime-time-without-time-zone-time-without-time-zone-22d32301">`mysql.addtime(time without time zone, time without time zone) → time without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1725-L1731) |
| <a id="mysql-addtime-timestamp-without-time-zone-double-precision-83e68c15" href="#mysql-addtime-timestamp-without-time-zone-double-precision-83e68c15">`mysql.addtime(timestamp without time zone, double precision) → timestamp without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2083-L2091) |
| <a id="mysql-addtime-timestamp-without-time-zone-pg-catalog-text-197d4832" href="#mysql-addtime-timestamp-without-time-zone-pg-catalog-text-197d4832">`mysql.addtime(timestamp without time zone, text) → timestamp without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1699-L1702) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L160-L164) |
| <a id="mysql-addtime-timestamp-without-time-zone-time-without-time-zone-4e752b99" href="#mysql-addtime-timestamp-without-time-zone-time-without-time-zone-4e752b99">`mysql.addtime(timestamp without time zone, time without time zone) → timestamp without time zone`</a> | 将两个时间值相加。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1720-L1723) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L167-L171) |

## convert_tz {#convert_tz}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-convert-tz-pg-catalog-text-pg-catalog-text-pg-catalog-text-6797d8a9" href="#mysql-convert-tz-pg-catalog-text-pg-catalog-text-pg-catalog-text-6797d8a9">`mysql.convert_tz(text, text, text) → timestamp without time zone`</a> | 在两个时区之间转换时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L429-L440) |
| <a id="mysql-convert-tz-timestamp-without-time-zone-pg-catalog-text-pg-catalog-text-86e57512" href="#mysql-convert-tz-timestamp-without-time-zone-pg-catalog-text-pg-catalog-text-86e57512">`mysql.convert_tz(timestamp without time zone, text, text) → timestamp without time zone`</a> | 在两个时区之间转换时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L414-L427) |

## curdate {#curdate}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-curdate-5abe5086" href="#mysql-curdate-5abe5086">`mysql.curdate() → date`</a> | 返回当前日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L282-L288) |

## curtime {#curtime}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-curtime-ece702ae" href="#mysql-curtime-ece702ae">`mysql.curtime() → time without time zone`</a> | 返回当前时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L322-L328) |
| <a id="mysql-curtime-integer-0f83720f" href="#mysql-curtime-integer-0f83720f">`mysql.curtime(prec integer) → time without time zone`</a> | 返回当前时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2033-L2063) |

## date {#date}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-date-numeric-8101441c" href="#mysql-date-numeric-8101441c">`mysql.date(numeric) → date`</a> | 提取日期部分或将输入解析为日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1925-L1939) |
| <a id="pg-catalog-date-pg-catalog-text-6a1f2744" href="#pg-catalog-date-pg-catalog-text-6a1f2744">`pg_catalog.date(text) → date`</a> | 提取日期部分或将输入解析为日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L8-L9) |

## date_add {#date_add}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-date-add-pg-catalog-date-interval-b475b4cd" href="#mysql-date-add-pg-catalog-date-interval-b475b4cd">`mysql.date_add(date, interval) → date`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L516-L522) |
| <a id="mysql-date-add-numeric-interval-42398723" href="#mysql-date-add-numeric-interval-42398723">`mysql.date_add(numeric, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L532-L538) |
| <a id="mysql-date-add-pg-catalog-text-interval-a4c94ca8" href="#mysql-date-add-pg-catalog-text-interval-a4c94ca8">`mysql.date_add(text, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L524-L530) |
| <a id="mysql-date-add-timestamp-without-time-zone-interval-01a8d854" href="#mysql-date-add-timestamp-without-time-zone-interval-01a8d854">`mysql.date_add(timestamp without time zone, interval) → timestamp without time zone`</a> | 为日期加上天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L507-L513) |

## date_format {#date_format}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-date-format-pg-catalog-text-pg-catalog-text-eff829cd" href="#mysql-date-format-pg-catalog-text-pg-catalog-text-eff829cd">`mysql.date_format(text, text) → text`</a> | 用 MySQL 百分号格式符格式化日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2194-L2200) |
| <a id="mysql-date-format-timestamp-with-time-zone-pg-catalog-text-334cd9ec" href="#mysql-date-format-timestamp-with-time-zone-pg-catalog-text-334cd9ec">`mysql.date_format(timestamp with time zone, text) → text`</a> | 用 MySQL 百分号格式符格式化日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L47-L115) |

## date_sub {#date_sub}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-date-sub-pg-catalog-date-interval-f3132f66" href="#mysql-date-sub-pg-catalog-date-interval-f3132f66">`mysql.date_sub(date, interval) → date`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L546-L549) |
| <a id="mysql-date-sub-numeric-interval-feed6b18" href="#mysql-date-sub-numeric-interval-feed6b18">`mysql.date_sub(numeric, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L558-L561) |
| <a id="mysql-date-sub-pg-catalog-text-interval-52994c25" href="#mysql-date-sub-pg-catalog-text-interval-52994c25">`mysql.date_sub(text, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L551-L556) |
| <a id="mysql-date-sub-timestamp-without-time-zone-interval-42bcd103" href="#mysql-date-sub-timestamp-without-time-zone-interval-42bcd103">`mysql.date_sub(timestamp without time zone, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L540-L543) |

## datediff {#datediff}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-datediff-pg-catalog-date-pg-catalog-date-0f334cb6" href="#mysql-datediff-pg-catalog-date-pg-catalog-date-0f334cb6">`mysql.datediff(date, date) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L627-L630) |
| <a id="mysql-datediff-numeric-numeric-4b4cbbfd" href="#mysql-datediff-numeric-numeric-4b4cbbfd">`mysql.datediff(numeric, numeric) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L642-L645) |
| <a id="mysql-datediff-numeric-pg-catalog-text-bda1b1bb" href="#mysql-datediff-numeric-pg-catalog-text-bda1b1bb">`mysql.datediff(numeric, text) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1663-L1666) |
| <a id="mysql-datediff-pg-catalog-text-numeric-7e3389c4" href="#mysql-datediff-pg-catalog-text-numeric-7e3389c4">`mysql.datediff(text, numeric) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1668-L1671) |
| <a id="mysql-datediff-pg-catalog-text-pg-catalog-text-e57a72db" href="#mysql-datediff-pg-catalog-text-pg-catalog-text-e57a72db">`mysql.datediff(text, text) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L637-L640) |
| <a id="mysql-datediff-pg-catalog-text-timestamp-without-time-zone-8a0e706b" href="#mysql-datediff-pg-catalog-text-timestamp-without-time-zone-8a0e706b">`mysql.datediff(text, timestamp without time zone) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2186-L2192) |
| <a id="mysql-datediff-timestamp-without-time-zone-pg-catalog-text-a898b70a" href="#mysql-datediff-timestamp-without-time-zone-pg-catalog-text-a898b70a">`mysql.datediff(timestamp without time zone, text) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2178-L2184) |
| <a id="mysql-datediff-timestamp-without-time-zone-timestamp-without-time-zone-e3d1e01d" href="#mysql-datediff-timestamp-without-time-zone-timestamp-without-time-zone-e3d1e01d">`mysql.datediff(timestamp without time zone, timestamp without time zone) → integer`</a> | 计算两个日期相差的天数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L632-L635) |

## day {#day}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-day-numeric-9dde3d54" href="#mysql-day-numeric-9dde3d54">`mysql.day(numeric) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L799-L803) |
| <a id="mysql-day-pg-catalog-text-785a9b25" href="#mysql-day-pg-catalog-text-785a9b25">`mysql.day(text) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L793-L797) |
| <a id="mysql-day-timestamp-without-time-zone-eee4db28" href="#mysql-day-timestamp-without-time-zone-eee4db28">`mysql.day(timestamp without time zone) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L788-L791) |

## dayname {#dayname}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-dayname-numeric-d911ea7d" href="#mysql-dayname-numeric-d911ea7d">`mysql.dayname(numeric) → text`</a> | 返回星期名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L816-L820) |
| <a id="mysql-dayname-pg-catalog-text-9c0382c5" href="#mysql-dayname-pg-catalog-text-9c0382c5">`mysql.dayname(text) → text`</a> | 返回星期名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L810-L814) |
| <a id="mysql-dayname-timestamp-without-time-zone-ec0763c4" href="#mysql-dayname-timestamp-without-time-zone-ec0763c4">`mysql.dayname(timestamp without time zone) → text`</a> | 返回星期名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L805-L808) |

## dayofmonth {#dayofmonth}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-dayofmonth-numeric-a91b1a05" href="#mysql-dayofmonth-numeric-a91b1a05">`mysql.dayofmonth(numeric) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L833-L836) |
| <a id="mysql-dayofmonth-pg-catalog-text-f4a3eb16" href="#mysql-dayofmonth-pg-catalog-text-f4a3eb16">`mysql.dayofmonth(text) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L828-L831) |
| <a id="mysql-dayofmonth-timestamp-without-time-zone-380fc1ab" href="#mysql-dayofmonth-timestamp-without-time-zone-380fc1ab">`mysql.dayofmonth(timestamp without time zone) → integer`</a> | 返回当月第几日。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L823-L826) |

## dayofweek {#dayofweek}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-dayofweek-numeric-9dcc5337" href="#mysql-dayofweek-numeric-9dcc5337">`mysql.dayofweek(numeric) → integer`</a> | 返回星期编号，周日为 1。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L849-L852) |
| <a id="mysql-dayofweek-pg-catalog-text-1a311ffa" href="#mysql-dayofweek-pg-catalog-text-1a311ffa">`mysql.dayofweek(text) → integer`</a> | 返回星期编号，周日为 1。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L844-L847) |
| <a id="mysql-dayofweek-timestamp-without-time-zone-2b8680ce" href="#mysql-dayofweek-timestamp-without-time-zone-2b8680ce">`mysql.dayofweek(timestamp without time zone) → integer`</a> | 返回星期编号，周日为 1。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L839-L842) |

## dayofyear {#dayofyear}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-dayofyear-numeric-d19063e6" href="#mysql-dayofyear-numeric-d19063e6">`mysql.dayofyear(numeric) → integer`</a> | 返回当年的第几天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L864-L867) |
| <a id="mysql-dayofyear-pg-catalog-text-a250bcc2" href="#mysql-dayofyear-pg-catalog-text-a250bcc2">`mysql.dayofyear(text) → integer`</a> | 返回当年的第几天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L859-L862) |
| <a id="mysql-dayofyear-timestamp-without-time-zone-301ebf23" href="#mysql-dayofyear-timestamp-without-time-zone-301ebf23">`mysql.dayofyear(timestamp without time zone) → integer`</a> | 返回当年的第几天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L854-L857) |

## extract {#extract}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-extract-pg-catalog-text-pg-catalog-text-d15bdb8a" href="#mysql-extract-pg-catalog-text-pg-catalog-text-d15bdb8a">`mysql."extract"(text, text) → numeric`</a> | 提取指定的日期或时间字段。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2143-L2151) |
| <a id="mysql-extract-pg-catalog-text-time-without-time-zone-c3a27494" href="#mysql-extract-pg-catalog-text-time-without-time-zone-c3a27494">`mysql."extract"(text, time without time zone) → numeric`</a> | 提取指定的日期或时间字段。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1307-L1311) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/date_func.c#L27-L31) |
| <a id="mysql-extract-pg-catalog-text-timestamp-without-time-zone-1f31c5e8" href="#mysql-extract-pg-catalog-text-timestamp-without-time-zone-1f31c5e8">`mysql."extract"(text, timestamp without time zone) → numeric`</a> | 提取指定的日期或时间字段。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1301-L1305) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/timestamp_func.c#L30-L34) |

## from_days {#from_days}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-from-days-integer-19492e05" href="#mysql-from-days-integer-19492e05">`mysql.from_days(integer) → date`</a> | 将 MySQL 日序号转换为日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1293-L1299) |

## from_unixtime {#from_unixtime}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-from-unixtime-double-precision-5c6f0df8" href="#mysql-from-unixtime-double-precision-5c6f0df8">`mysql.from_unixtime(double precision) → timestamp without time zone`</a> | 将 Unix 时间转换为日期时间值或格式化字符串。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L390-L393) |
| <a id="mysql-from-unixtime-double-precision-pg-catalog-text-5d1521b8" href="#mysql-from-unixtime-double-precision-pg-catalog-text-5d1521b8">`mysql.from_unixtime(double precision, text) → text`</a> | 将 Unix 时间转换为日期时间值或格式化字符串。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L395-L398) |

## hour {#hour}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-hour-pg-catalog-text-848a85f2" href="#mysql-hour-pg-catalog-text-848a85f2">`mysql.hour(text) → integer`</a> | 提取小时。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1158-L1164) |
| <a id="mysql-hour-time-without-time-zone-43266bd1" href="#mysql-hour-time-without-time-zone-43266bd1">`mysql.hour(time without time zone) → integer`</a> | 提取小时。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1142-L1148) |
| <a id="mysql-hour-timestamp-without-time-zone-841660c8" href="#mysql-hour-timestamp-without-time-zone-841660c8">`mysql.hour(timestamp without time zone) → integer`</a> | 提取小时。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1150-L1156) |

## last_day {#last_day}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-last-day-pg-catalog-date-aa8c428d" href="#mysql-last-day-pg-catalog-date-aa8c428d">`mysql.last_day(date) → date`</a> | 返回当月最后一天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L869-L881) |
| <a id="mysql-last-day-numeric-a9007272" href="#mysql-last-day-numeric-a9007272">`mysql.last_day(numeric) → date`</a> | 返回当月最后一天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1768-L1782) |
| <a id="mysql-last-day-pg-catalog-text-b03096aa" href="#mysql-last-day-pg-catalog-text-b03096aa">`mysql.last_day(text) → date`</a> | 返回当月最后一天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L915-L929) |
| <a id="mysql-last-day-timestamp-with-time-zone-74f3a027" href="#mysql-last-day-timestamp-with-time-zone-74f3a027">`mysql.last_day(timestamp with time zone) → date`</a> | 返回当月最后一天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L899-L913) |
| <a id="mysql-last-day-timestamp-without-time-zone-a7337344" href="#mysql-last-day-timestamp-without-time-zone-a7337344">`mysql.last_day(timestamp without time zone) → date`</a> | 返回当月最后一天。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L883-L897) |

## makedate {#makedate}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-makedate-integer-integer-5e56d9fd" href="#mysql-makedate-integer-integer-5e56d9fd">`mysql.makedate(integer, integer) → date`</a> | 按年份和年内日序号生成日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L400-L412) |

## maketime {#maketime}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-maketime-integer-integer-numeric-11eb49e4" href="#mysql-maketime-integer-integer-numeric-11eb49e4">`mysql.maketime(integer, integer, numeric) → time without time zone`</a> | 用时、分、秒生成时间值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1654-L1661) |

## microsecond {#microsecond}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-microsecond-pg-catalog-text-dda5c7f2" href="#mysql-microsecond-pg-catalog-text-dda5c7f2">`mysql.microsecond(text) → integer`</a> | 提取微秒。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1230-L1236) |
| <a id="mysql-microsecond-time-without-time-zone-e1395723" href="#mysql-microsecond-time-without-time-zone-e1395723">`mysql.microsecond(time without time zone) → integer`</a> | 提取微秒。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1214-L1220) |
| <a id="mysql-microsecond-timestamp-without-time-zone-6a967b14" href="#mysql-microsecond-timestamp-without-time-zone-6a967b14">`mysql.microsecond(timestamp without time zone) → integer`</a> | 提取微秒。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1222-L1228) |

## minute {#minute}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-minute-pg-catalog-text-d481ea1d" href="#mysql-minute-pg-catalog-text-d481ea1d">`mysql.minute(text) → integer`</a> | 提取分钟。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1182-L1188) |
| <a id="mysql-minute-time-without-time-zone-5bcd3086" href="#mysql-minute-time-without-time-zone-5bcd3086">`mysql.minute(time without time zone) → integer`</a> | 提取分钟。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1166-L1172) |
| <a id="mysql-minute-timestamp-without-time-zone-e83902be" href="#mysql-minute-timestamp-without-time-zone-e83902be">`mysql.minute(timestamp without time zone) → integer`</a> | 提取分钟。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1174-L1180) |

## month {#month}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-month-numeric-9bb05710" href="#mysql-month-numeric-9bb05710">`mysql.month(numeric) → integer`</a> | 返回月份编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L765-L769) |
| <a id="mysql-month-pg-catalog-text-0e13239b" href="#mysql-month-pg-catalog-text-0e13239b">`mysql.month(text) → integer`</a> | 返回月份编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L759-L763) |
| <a id="mysql-month-timestamp-without-time-zone-795c36fa" href="#mysql-month-timestamp-without-time-zone-795c36fa">`mysql.month(timestamp without time zone) → integer`</a> | 返回月份编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L754-L757) |

## monthname {#monthname}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-monthname-numeric-c60dee40" href="#mysql-monthname-numeric-c60dee40">`mysql.monthname(numeric) → text`</a> | 返回月份名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L782-L786) |
| <a id="mysql-monthname-pg-catalog-text-d846dba9" href="#mysql-monthname-pg-catalog-text-d846dba9">`mysql.monthname(text) → text`</a> | 返回月份名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L776-L780) |
| <a id="mysql-monthname-timestamp-without-time-zone-6c4d75cc" href="#mysql-monthname-timestamp-without-time-zone-6c4d75cc">`mysql.monthname(timestamp without time zone) → text`</a> | 返回月份名称。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L771-L774) |

## now {#now}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-now-3d4284a9" href="#mysql-now-3d4284a9">`mysql.now() → timestamp without time zone`</a> | 返回当前事务的时间戳。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L194-L200) |
| <a id="mysql-now-integer-fc7157ed" href="#mysql-now-integer-fc7157ed">`mysql.now(prec integer) → timestamp without time zone`</a> | 返回当前事务的时间戳。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L206-L238) |

## period_add {#period_add}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-period-add-integer-integer-805ddfa3" href="#mysql-period-add-integer-integer-805ddfa3">`mysql.period_add(integer, integer) → text`</a> | 给年月值加上指定月数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1849-L1890) |

## period_diff {#period_diff}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-period-diff-integer-integer-e113bc81" href="#mysql-period-diff-integer-integer-e113bc81">`mysql.period_diff(integer, integer) → integer`</a> | 按月计算两个年月值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1784-L1847) |

## quarter {#quarter}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-quarter-pg-catalog-date-4952d9b0" href="#mysql-quarter-pg-catalog-date-4952d9b0">`mysql.quarter(date) → integer`</a> | 返回季度编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1238-L1244) |
| <a id="mysql-quarter-numeric-69dcd871" href="#mysql-quarter-numeric-69dcd871">`mysql.quarter(numeric) → integer`</a> | 返回季度编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1673-L1679) |
| <a id="mysql-quarter-pg-catalog-text-54b32d3e" href="#mysql-quarter-pg-catalog-text-54b32d3e">`mysql.quarter(text) → integer`</a> | 返回季度编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1254-L1260) |
| <a id="mysql-quarter-timestamp-without-time-zone-6597f540" href="#mysql-quarter-timestamp-without-time-zone-6597f540">`mysql.quarter(timestamp without time zone) → integer`</a> | 返回季度编号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1246-L1252) |

## sec_to_time {#sec_to_time}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-sec-to-time-bigint-2571b2a1" href="#mysql-sec-to-time-bigint-2571b2a1">`mysql.sec_to_time(bigint) → time without time zone`</a> | 将秒数转换为时间值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1278-L1281) |

## second {#second}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-second-pg-catalog-text-21f582b5" href="#mysql-second-pg-catalog-text-21f582b5">`mysql.second(text) → integer`</a> | 提取秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1206-L1212) |
| <a id="mysql-second-time-without-time-zone-6db9e94a" href="#mysql-second-time-without-time-zone-6db9e94a">`mysql.second(time without time zone) → integer`</a> | 提取秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1190-L1196) |
| <a id="mysql-second-timestamp-without-time-zone-20d00560" href="#mysql-second-timestamp-without-time-zone-20d00560">`mysql.second(timestamp without time zone) → integer`</a> | 提取秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1198-L1204) |

## str_to_date {#str_to_date}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-str-to-date-pg-catalog-text-pg-catalog-text-7b3d6d6d" href="#mysql-str-to-date-pg-catalog-text-pg-catalog-text-7b3d6d6d">`mysql.str_to_date(text, text) → timestamp without time zone`</a> | 按 MySQL 格式串解析日期或时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L120-L192) |

## subdate {#subdate}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-subdate-pg-catalog-date-integer-14ed34a8" href="#mysql-subdate-pg-catalog-date-integer-14ed34a8">`mysql.subdate(date, integer) → date`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L603-L609) |
| <a id="mysql-subdate-pg-catalog-date-interval-04f43808" href="#mysql-subdate-pg-catalog-date-interval-04f43808">`mysql.subdate(date, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L571-L577) |
| <a id="mysql-subdate-numeric-integer-9a6e4ee7" href="#mysql-subdate-numeric-integer-9a6e4ee7">`mysql.subdate(numeric, integer) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L619-L625) |
| <a id="mysql-subdate-numeric-interval-1c5bf48d" href="#mysql-subdate-numeric-interval-1c5bf48d">`mysql.subdate(numeric, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L587-L593) |
| <a id="mysql-subdate-pg-catalog-text-integer-ff88113e" href="#mysql-subdate-pg-catalog-text-integer-ff88113e">`mysql.subdate(text, integer) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L611-L617) |
| <a id="mysql-subdate-pg-catalog-text-interval-ae67c618" href="#mysql-subdate-pg-catalog-text-interval-ae67c618">`mysql.subdate(text, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L579-L585) |
| <a id="mysql-subdate-timestamp-without-time-zone-integer-78b9bf73" href="#mysql-subdate-timestamp-without-time-zone-integer-78b9bf73">`mysql.subdate(timestamp without time zone, integer) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L595-L601) |
| <a id="mysql-subdate-timestamp-without-time-zone-interval-00f6a039" href="#mysql-subdate-timestamp-without-time-zone-interval-00f6a039">`mysql.subdate(timestamp without time zone, interval) → timestamp without time zone`</a> | 从日期中减去天数或时间间隔。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L563-L569) |

## subtime {#subtime}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-subtime-pg-catalog-text-double-precision-74927a0d" href="#mysql-subtime-pg-catalog-text-double-precision-74927a0d">`mysql.subtime(text, double precision) → text`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2133-L2141) |
| <a id="mysql-subtime-pg-catalog-text-pg-catalog-text-835d0c76" href="#mysql-subtime-pg-catalog-text-pg-catalog-text-835d0c76">`mysql.subtime(text, text) → text`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1762-L1766) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L188-L201) |
| <a id="mysql-subtime-pg-catalog-text-time-without-time-zone-99a597bb" href="#mysql-subtime-pg-catalog-text-time-without-time-zone-99a597bb">`mysql.subtime(text, time without time zone) → text`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1739-L1746) |
| <a id="mysql-subtime-time-without-time-zone-double-precision-4a9bbf1d" href="#mysql-subtime-time-without-time-zone-double-precision-4a9bbf1d">`mysql.subtime(time without time zone, double precision) → time without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2123-L2131) |
| <a id="mysql-subtime-time-without-time-zone-pg-catalog-text-cd957fa1" href="#mysql-subtime-time-without-time-zone-pg-catalog-text-cd957fa1">`mysql.subtime(time without time zone, text) → time without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L727-L734) |
| <a id="mysql-subtime-time-without-time-zone-time-without-time-zone-1c623c4f" href="#mysql-subtime-time-without-time-zone-time-without-time-zone-1c623c4f">`mysql.subtime(time without time zone, time without time zone) → time without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1753-L1760) |
| <a id="mysql-subtime-timestamp-without-time-zone-double-precision-c3f6a493" href="#mysql-subtime-timestamp-without-time-zone-double-precision-c3f6a493">`mysql.subtime(timestamp without time zone, double precision) → timestamp without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2113-L2121) |
| <a id="mysql-subtime-timestamp-without-time-zone-pg-catalog-text-154b1ef8" href="#mysql-subtime-timestamp-without-time-zone-pg-catalog-text-154b1ef8">`mysql.subtime(timestamp without time zone, text) → timestamp without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L722-L725) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L174-L178) |
| <a id="mysql-subtime-timestamp-without-time-zone-time-without-time-zone-b1b9e8c3" href="#mysql-subtime-timestamp-without-time-zone-time-without-time-zone-b1b9e8c3">`mysql.subtime(timestamp without time zone, time without time zone) → timestamp without time zone`</a> | 计算两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1748-L1751) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L181-L185) |

## sysdate {#sysdate}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-sysdate-0fecc235" href="#mysql-sysdate-0fecc235">`mysql.sysdate() → timestamp without time zone`</a> | 返回函数执行时的时钟时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L240-L246) |
| <a id="mysql-sysdate-integer-34527f64" href="#mysql-sysdate-integer-34527f64">`mysql.sysdate(prec integer) → timestamp without time zone`</a> | 返回函数执行时的时钟时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L248-L280) |

## time_format {#time_format}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-time-format-time-without-time-zone-pg-catalog-text-a85b89f0" href="#mysql-time-format-time-without-time-zone-pg-catalog-text-a85b89f0">`mysql.time_format(time without time zone, text) → text`</a> | 格式化时间值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1566-L1644) |

## time_to_sec {#time_to_sec}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-time-to-sec-pg-catalog-text-471a14c4" href="#mysql-time-to-sec-pg-catalog-text-471a14c4">`mysql.time_to_sec(text) → bigint`</a> | 将时间值换算为秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1272-L1275) |
| <a id="mysql-time-to-sec-time-without-time-zone-7b627f14" href="#mysql-time-to-sec-time-without-time-zone-7b627f14">`mysql.time_to_sec(time without time zone) → bigint`</a> | 将时间值换算为秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1267-L1270) |
| <a id="mysql-time-to-sec-timestamp-without-time-zone-a83021d9" href="#mysql-time-to-sec-timestamp-without-time-zone-a83021d9">`mysql.time_to_sec(timestamp without time zone) → bigint`</a> | 将时间值换算为秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1262-L1265) |

## timediff {#timediff}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-timediff-pg-catalog-text-pg-catalog-text-25d113c7" href="#mysql-timediff-pg-catalog-text-pg-catalog-text-25d113c7">`mysql.timediff(text, text) → text`</a> | 返回两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1681-L1685) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L282-L300) |
| <a id="mysql-timediff-time-without-time-zone-time-without-time-zone-cdfa09dc" href="#mysql-timediff-time-without-time-zone-time-without-time-zone-cdfa09dc">`mysql.timediff(time without time zone, time without time zone) → text`</a> | 返回两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1687-L1691) |
| <a id="mysql-timediff-timestamp-without-time-zone-timestamp-without-time-zone-e9c95ed4" href="#mysql-timediff-timestamp-without-time-zone-timestamp-without-time-zone-e9c95ed4">`mysql.timediff(timestamp without time zone, timestamp without time zone) → text`</a> | 返回两个时间值之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1693-L1696) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/time_func.c#L303-L319) |

## timestamp {#timestamp}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-timestamp-pg-catalog-text-pg-catalog-text-94314fe9" href="#mysql-timestamp-pg-catalog-text-pg-catalog-text-94314fe9">`mysql."timestamp"(text, text) → timestamp without time zone`</a> | 根据输入的日期和时间构造时间戳。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2163-L2176) |

## timestampadd {#timestampadd}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-timestampadd-pg-catalog-text-integer-timestamp-without-time-zone-b3002264" href="#mysql-timestampadd-pg-catalog-text-integer-timestamp-without-time-zone-b3002264">`mysql.timestampadd(text, integer, timestamp without time zone) → timestamp without time zone`</a> | 按指定时间单位增加给定数量。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L19-L37) |

## timestampdiff {#timestampdiff}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-timestampdiff-pg-catalog-text-pg-catalog-text-pg-catalog-text-770e6164" href="#mysql-timestampdiff-pg-catalog-text-pg-catalog-text-pg-catalog-text-770e6164">`mysql.timestampdiff(unit text, ts1 text, ts2 text) → bigint`</a> | 按指定单位计算时间戳之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2153-L2161) |
| <a id="mysql-timestampdiff-pg-catalog-text-timestamp-without-time-zone-timestamp-without-tim-ea5f7bb6" href="#mysql-timestampdiff-pg-catalog-text-timestamp-without-time-zone-timestamp-without-tim-ea5f7bb6">`mysql.timestampdiff(unit text, ts1 timestamp without time zone, ts2 timestamp without time zone) → bigint`</a> | 按指定单位计算时间戳之差。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L39-L45) · [C](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/src/mysm/timestamp_func.c#L37-L187) |

## to_days {#to_days}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-to-days-pg-catalog-date-210812ac" href="#mysql-to-days-pg-catalog-date-210812ac">`mysql.to_days(date) → integer`</a> | 将日期换算为 MySQL 日序号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1285-L1291) |
| <a id="mysql-to-days-pg-catalog-text-62974832" href="#mysql-to-days-pg-catalog-text-62974832">`mysql.to_days(text) → integer`</a> | 将日期换算为 MySQL 日序号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2065-L2072) |
| <a id="mysql-to-days-timestamp-without-time-zone-e3e48389" href="#mysql-to-days-timestamp-without-time-zone-e3e48389">`mysql.to_days(timestamp without time zone) → integer`</a> | 将日期换算为 MySQL 日序号。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L2074-L2081) |

## unix_timestamp {#unix_timestamp}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-unix-timestamp-713b435a" href="#mysql-unix-timestamp-713b435a">`mysql.unix_timestamp() → bigint`</a> | 返回自 Unix 纪元起的秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L380-L383) |
| <a id="mysql-unix-timestamp-numeric-a342e29e" href="#mysql-unix-timestamp-numeric-a342e29e">`mysql.unix_timestamp(numeric) → numeric`</a> | 返回自 Unix 纪元起的秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1908-L1923) |
| <a id="mysql-unix-timestamp-pg-catalog-text-f5a20fde" href="#mysql-unix-timestamp-pg-catalog-text-f5a20fde">`mysql.unix_timestamp(text) → numeric`</a> | 返回自 Unix 纪元起的秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1892-L1906) |
| <a id="mysql-unix-timestamp-timestamp-without-time-zone-74e5628b" href="#mysql-unix-timestamp-timestamp-without-time-zone-74e5628b">`mysql.unix_timestamp(timestamp without time zone) → numeric`</a> | 返回自 Unix 纪元起的秒数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L385-L388) |

## utc_date {#utc_date}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-utc-date-41dcf681" href="#mysql-utc-date-41dcf681">`mysql.utc_date() → date`</a> | 返回 UTC 当前日期。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1941-L1947) |

## utc_time {#utc_time}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-utc-time-cd463eb4" href="#mysql-utc-time-cd463eb4">`mysql.utc_time() → time without time zone`</a> | 返回 UTC 当前时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1949-L1955) |
| <a id="mysql-utc-time-integer-d4b4538c" href="#mysql-utc-time-integer-d4b4538c">`mysql.utc_time(prec integer) → time without time zone`</a> | 返回 UTC 当前时间。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1957-L1989) |

## utc_timestamp {#utc_timestamp}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-utc-timestamp-97655c2d" href="#mysql-utc-timestamp-97655c2d">`mysql.utc_timestamp() → timestamp without time zone`</a> | 返回当前 UTC 时间戳。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1991-L1997) |
| <a id="mysql-utc-timestamp-integer-3781f443" href="#mysql-utc-timestamp-integer-3781f443">`mysql.utc_timestamp(prec integer) → timestamp without time zone`</a> | 返回当前 UTC 时间戳。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1999-L2031) |

## week {#week}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-week-numeric-1123418e" href="#mysql-week-numeric-1123418e">`mysql.week(numeric) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1037-L1040) |
| <a id="mysql-week-numeric-integer-b333a9af" href="#mysql-week-numeric-integer-b333a9af">`mysql.week(numeric, integer) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1032-L1035) |
| <a id="mysql-week-pg-catalog-text-d42ab33b" href="#mysql-week-pg-catalog-text-d42ab33b">`mysql.week(text) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1027-L1030) |
| <a id="mysql-week-pg-catalog-text-integer-be6d01e2" href="#mysql-week-pg-catalog-text-integer-be6d01e2">`mysql.week(text, integer) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1022-L1025) |
| <a id="mysql-week-timestamp-without-time-zone-463ea059" href="#mysql-week-timestamp-without-time-zone-463ea059">`mysql.week(timestamp without time zone) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1017-L1020) |
| <a id="mysql-week-timestamp-without-time-zone-integer-4b265035" href="#mysql-week-timestamp-without-time-zone-integer-4b265035">`mysql.week(timestamp without time zone, integer) → integer`</a> | 按周编号模式返回周数。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1012-L1015) |

## weekday {#weekday}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-weekday-numeric-cec23e55" href="#mysql-weekday-numeric-cec23e55">`mysql.weekday(numeric) → integer`</a> | 返回星期编号，周一为 0。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1132-L1140) |
| <a id="mysql-weekday-pg-catalog-text-732d6b06" href="#mysql-weekday-pg-catalog-text-732d6b06">`mysql.weekday(text) → integer`</a> | 返回星期编号，周一为 0。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1122-L1130) |
| <a id="mysql-weekday-timestamp-without-time-zone-00beacd9" href="#mysql-weekday-timestamp-without-time-zone-00beacd9">`mysql.weekday(timestamp without time zone) → integer`</a> | 返回星期编号，周一为 0。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1112-L1120) |

## weekofyear {#weekofyear}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-weekofyear-numeric-9234d926" href="#mysql-weekofyear-numeric-9234d926">`mysql.weekofyear(numeric) → integer`</a> | 返回当年的第几周。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1053-L1056) |
| <a id="mysql-weekofyear-pg-catalog-text-1cbe7a4e" href="#mysql-weekofyear-pg-catalog-text-1cbe7a4e">`mysql.weekofyear(text) → integer`</a> | 返回当年的第几周。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1048-L1051) |
| <a id="mysql-weekofyear-timestamp-without-time-zone-39e7fc58" href="#mysql-weekofyear-timestamp-without-time-zone-39e7fc58">`mysql.weekofyear(timestamp without time zone) → integer`</a> | 返回当年的第几周。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1043-L1046) |

## year {#year}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-year-pg-catalog-date-76f88011" href="#mysql-year-pg-catalog-date-76f88011">`mysql.year(date) → integer`</a> | 提取年份。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L11-L17) |
| <a id="mysql-year-numeric-4f250ebc" href="#mysql-year-numeric-4f250ebc">`mysql.year(numeric) → integer`</a> | 提取年份。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L748-L752) |
| <a id="mysql-year-pg-catalog-text-6ceda4c1" href="#mysql-year-pg-catalog-text-6ceda4c1">`mysql.year(text) → integer`</a> | 提取年份。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L742-L746) |
| <a id="mysql-year-timestamp-without-time-zone-4a361946" href="#mysql-year-timestamp-without-time-zone-4a361946">`mysql.year(timestamp without time zone) → integer`</a> | 提取年份。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L736-L740) |

## yearweek {#yearweek}

| 对象签名 | 用途 | 源码定义 |
|---|---|---|
| <a id="mysql-yearweek-numeric-b5bb736b" href="#mysql-yearweek-numeric-b5bb736b">`mysql.yearweek(numeric) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1105-L1108) |
| <a id="mysql-yearweek-numeric-integer-7aadea93" href="#mysql-yearweek-numeric-integer-7aadea93">`mysql.yearweek(qdate numeric, mode integer) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1093-L1103) |
| <a id="mysql-yearweek-pg-catalog-text-integer-91a3a96e" href="#mysql-yearweek-pg-catalog-text-integer-91a3a96e">`mysql.yearweek(qdate text, mode integer) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1076-L1086) |
| <a id="mysql-yearweek-timestamp-without-time-zone-integer-8cfc6973" href="#mysql-yearweek-timestamp-without-time-zone-integer-8cfc6973">`mysql.yearweek(qdate timestamp without time zone, mode integer) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1059-L1069) |
| <a id="mysql-yearweek-pg-catalog-text-43d2490f" href="#mysql-yearweek-pg-catalog-text-43d2490f">`mysql.yearweek(text) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1088-L1091) |
| <a id="mysql-yearweek-timestamp-without-time-zone-000e59c1" href="#mysql-yearweek-timestamp-without-time-zone-000e59c1">`mysql.yearweek(timestamp without time zone) → integer`</a> | 返回周年和周数组合值。 | [SQL](https://github.com/pgsty/pg_mysql/blob/0d51adcf5151ca5c98bc61de84f287ec3b4fe4a3/sql/baseline/44-func-time.sql#L1071-L1074) |

---

反链：

- [函数](/zh/docs/mysql/reference/objects/functions/)
