From d352e821a033aa2a3787620dbd9ed9dfefee2a26 Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Thu, 22 Sep 2022 19:32:40 +0800 Subject: [PATCH] Optimized date function doc order and add partial function doc --- .../date-time-functions/days_diff.md | 48 ++++++++++++ .../date-time-functions/extract.md | 53 +++++++++++++ .../date-time-functions/hours_diff.md | 48 ++++++++++++ .../date-time-functions/localtime.md | 56 ++++++++++++++ .../date-time-functions/minutes_diff.md | 48 ++++++++++++ .../date-time-functions/months_diff.md | 48 ++++++++++++ .../date-time-functions/quarter.md | 48 ++++++++++++ .../date-time-functions/seconds_diff.md | 48 ++++++++++++ .../date-time-functions/weeks_diff.md | 48 ++++++++++++ .../date-time-functions/year_floor.md | 48 ++++++++++++ .../date-time-functions/years_diff.md | 48 ++++++++++++ docs/sidebars.json | 75 +++++++++++-------- .../date-time-functions/days_diff.md | 48 ++++++++++++ .../date-time-functions/extract.md | 53 +++++++++++++ .../date-time-functions/hours_diff.md | 48 ++++++++++++ .../date-time-functions/localtime.md | 56 ++++++++++++++ .../date-time-functions/minutes_diff.md | 48 ++++++++++++ .../date-time-functions/months_diff.md | 48 ++++++++++++ .../date-time-functions/quarter.md | 48 ++++++++++++ .../date-time-functions/seconds_diff.md | 48 ++++++++++++ .../date-time-functions/weeks_diff.md | 48 ++++++++++++ .../date-time-functions/year_floor.md | 48 ++++++++++++ .../date-time-functions/years_diff.md | 48 ++++++++++++ 23 files changed, 1125 insertions(+), 32 deletions(-) create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/days_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/extract.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/localtime.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/months_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/quarter.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/year_floor.md create mode 100644 docs/en/docs/sql-manual/sql-functions/date-time-functions/years_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/days_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/extract.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/localtime.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/months_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/quarter.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/year_floor.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/years_diff.md diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/days_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/days_diff.md new file mode 100644 index 00000000000000..183fe927b18b34 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/days_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "days_diff", + "language": "en" +} +--- + + + +## days_diff +### description +#### Syntax + +`INT days_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is a few days + +### example + +``` +mysql> select days_diff('2020-12-25 22:00:00','2020-12-24 22:00:00'); ++---------------------------------------------------------+ +| days_diff('2020-12-25 22:00:00', '2020-12-24 22:00:00') | ++---------------------------------------------------------+ +| 1 | ++---------------------------------------------------------+ +``` + +### keywords + + days_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/extract.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/extract.md new file mode 100644 index 00000000000000..5651e4a132e463 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/extract.md @@ -0,0 +1,53 @@ +--- +{ + "title": "extract", + "language": "en" +} +--- + + + +## extract +### description +#### Syntax + +`INT extract(unit FROM DATETIME)` + +Extract DATETIME The value of a specified unit. The unit can be year, day, hour, minute, or second + +### Example + +``` +mysql> select extract(year from '2022-09-22 17:01:30') as year, + -> extract(month from '2022-09-22 17:01:30') as month, + -> extract(day from '2022-09-22 17:01:30') as day, + -> extract(hour from '2022-09-22 17:01:30') as hour, + -> extract(minute from '2022-09-22 17:01:30') as minute, + -> extract(second from '2022-09-22 17:01:30') as second; ++------+-------+------+------+--------+--------+ +| year | month | day | hour | minute | second | ++------+-------+------+------+--------+--------+ +| 2022 | 9 | 22 | 17 | 1 | 30 | ++------+-------+------+------+--------+--------+ +``` + +### keywords + + extract diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md new file mode 100644 index 00000000000000..faaafa9a6c3f50 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "hours_diff", + "language": "en" +} +--- + + + +## hours_diff +### description +#### Syntax + +`INT hours_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is a few hours + +### example + +``` +mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++----------------------------------------------------------+ +| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++----------------------------------------------------------+ +| 1 | ++----------------------------------------------------------+ +``` + +### keywords + + hours_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/localtime.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/localtime.md new file mode 100644 index 00000000000000..e4d7f222fc4a80 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/localtime.md @@ -0,0 +1,56 @@ +--- +{ + "title": "localtime,localtimestamp", + "language": "en" +} +--- + + + +## localtime,localtimestamp +### description +#### Syntax + +`DATETIME localtime()` +`DATETIME localtimestamp()` + +Get the current time and return it in Datetime type. + +### Example + +``` +mysql> select localtime(); ++---------------------+ +| localtime() | ++---------------------+ +| 2022-09-22 17:30:23 | ++---------------------+ + +mysql> select localtimestamp(); ++---------------------+ +| localtimestamp() | ++---------------------+ +| 2022-09-22 17:30:29 | ++---------------------+ +``` + +### keywords + + localtime,localtimestamp diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md new file mode 100644 index 00000000000000..484bd040de235e --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "minutes_diff", + "language": "en" +} +--- + + + +## minutes_diff +### description +#### Syntax + +`INT minutes_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is a few minutes + +### example + +``` +mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++------------------------------------------------------------+ +| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++------------------------------------------------------------+ +| 60 | ++------------------------------------------------------------+ +``` + +### keywords + + minutes_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/months_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/months_diff.md new file mode 100644 index 00000000000000..67398388c59fbb --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/months_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "months_diff", + "language": "en" +} +--- + + + +## months_diff +### description +#### Syntax + +`INT months_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is months + +### example + +``` +mysql> select months_diff('2020-12-25','2020-10-25'); ++-----------------------------------------------------------+ +| months_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | ++-----------------------------------------------------------+ +| 2 | ++-----------------------------------------------------------+ +``` + +### keywords + + months_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/quarter.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/quarter.md new file mode 100644 index 00000000000000..82c971b7265e57 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/quarter.md @@ -0,0 +1,48 @@ +--- +{ + "title": "quarter", + "language": "en" +} +--- + + + +## quarter +### description +#### Syntax + +`INT quarter(DATETIME date)` + +Returns the quarter to which the specified date belongs, as an INT + +### Example + +``` +mysql> select quarter('2022-09-22 17:00:00'); ++--------------------------------+ +| quarter('2022-09-22 17:00:00') | ++--------------------------------+ +| 3 | ++--------------------------------+ +``` + +### keywords + + quarter diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md new file mode 100644 index 00000000000000..83282713847874 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "seconds_diff", + "language": "en" +} +--- + + + +## seconds_diff +### description +#### Syntax + +`INT seconds_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is seconds + +### example + +``` +mysql> select seconds_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++------------------------------------------------------------+ +| seconds_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++------------------------------------------------------------+ +| 3600 | ++------------------------------------------------------------+ +``` + +### keywords + + seconds_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md new file mode 100644 index 00000000000000..82aa49db198a4a --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "weeks_diff", + "language": "en" +} +--- + + + +## weeks_diff +### description +#### Syntax + +`INT weeks_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is weeks + +### example + +``` +mysql> select weeks_diff('2020-12-25','2020-10-25'); ++----------------------------------------------------------+ +| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | ++----------------------------------------------------------+ +| 8 | ++----------------------------------------------------------+ +``` + +### keywords + + weeks_diff diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/year_floor.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/year_floor.md new file mode 100644 index 00000000000000..169655ba20c89a --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/year_floor.md @@ -0,0 +1,48 @@ +--- +{ + "title": "year_floor", + "language": "en" +} +--- + + + +## year_floor +### description +#### Syntax + +`DATETIME year_floor(DATETIME date)` + +Rounding down the specified time, reserving the field level to years, returns the DATETIME type + +### Example + +``` +mysql> select year_floor('2022-09-22 17:00:00'); ++-----------------------------------+ +| year_floor('2022-09-22 17:00:00') | ++-----------------------------------+ +| 2022-01-01 00:00:00 | ++-----------------------------------+ +``` + +### keywords + + year_floor diff --git a/docs/en/docs/sql-manual/sql-functions/date-time-functions/years_diff.md b/docs/en/docs/sql-manual/sql-functions/date-time-functions/years_diff.md new file mode 100644 index 00000000000000..c8598e2be05da6 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/date-time-functions/years_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "years_diff", + "language": "en" +} +--- + + + +## years_diff +### description +#### Syntax + +`INT years_diff(DATETIME enddate, DATETIME startdate)` + +The difference between the start time and the end time is several years + +### example + +``` +mysql> select years_diff('2020-12-25','2019-10-25'); ++----------------------------------------------------------+ +| years_diff('2020-12-25 00:00:00', '2019-10-25 00:00:00') | ++----------------------------------------------------------+ +| 1 | ++----------------------------------------------------------+ +``` + +### keywords + + years_diff diff --git a/docs/sidebars.json b/docs/sidebars.json index d31e4de13eccba..39712c24f7729a 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -113,7 +113,7 @@ { "type": "category", "label": "Advanced Usage", - "items": [ + "items": [ { "type": "category", "label": "Alter Table", @@ -121,7 +121,7 @@ "advanced/alter-table/schema-change", "advanced/alter-table/replace-table" ] - }, + }, { "type": "category", "label": "Doris Partition", @@ -129,7 +129,7 @@ "advanced/partition/dynamic-partition", "advanced/partition/table-temp-partition" ] - }, + }, { "type": "category", "label": "Date Cache", @@ -157,7 +157,7 @@ "advanced/best-practice/import-analysis", "advanced/best-practice/debug-log" ] - }, + }, "advanced/resource", "advanced/orthogonal-bitmap-manual", "advanced/using-hll", @@ -263,56 +263,67 @@ "type": "category", "label": "Date Functions", "items": [ + "sql-manual/sql-functions/date-time-functions/convert_tz", + "sql-manual/sql-functions/date-time-functions/curdate", + "sql-manual/sql-functions/date-time-functions/curtime", + "sql-manual/sql-functions/date-time-functions/current_timestamp", + "sql-manual/sql-functions/date-time-functions/localtime", + "sql-manual/sql-functions/date-time-functions/now", + "sql-manual/sql-functions/date-time-functions/year", + "sql-manual/sql-functions/date-time-functions/quarter", + "sql-manual/sql-functions/date-time-functions/month", + "sql-manual/sql-functions/date-time-functions/day", + "sql-manual/sql-functions/date-time-functions/dayofyear", + "sql-manual/sql-functions/date-time-functions/dayofmonth", + "sql-manual/sql-functions/date-time-functions/dayofweek", + "sql-manual/sql-functions/date-time-functions/week", + "sql-manual/sql-functions/date-time-functions/weekday", + "sql-manual/sql-functions/date-time-functions/weekofyear", + "sql-manual/sql-functions/date-time-functions/yearweek", "sql-manual/sql-functions/date-time-functions/dayname", + "sql-manual/sql-functions/date-time-functions/monthname", + "sql-manual/sql-functions/date-time-functions/year_floor", + "sql-manual/sql-functions/date-time-functions/hour", "sql-manual/sql-functions/date-time-functions/minute", + "sql-manual/sql-functions/date-time-functions/second", + "sql-manual/sql-functions/date-time-functions/from_days", "sql-manual/sql-functions/date-time-functions/from_unixtime", - "sql-manual/sql-functions/date-time-functions/hour", - "sql-manual/sql-functions/date-time-functions/monthname", - "sql-manual/sql-functions/date-time-functions/date_sub", - "sql-manual/sql-functions/date-time-functions/yearweek", "sql-manual/sql-functions/date-time-functions/unix_timestamp", - "sql-manual/sql-functions/date-time-functions/day", - "sql-manual/sql-functions/date-time-functions/curtime", - "sql-manual/sql-functions/date-time-functions/month", - "sql-manual/sql-functions/date-time-functions/week", + "sql-manual/sql-functions/date-time-functions/utc_timestamp", "sql-manual/sql-functions/date-time-functions/to_date", - "sql-manual/sql-functions/date-time-functions/timediff", + "sql-manual/sql-functions/date-time-functions/to_days", + "sql-manual/sql-functions/date-time-functions/extract", "sql-manual/sql-functions/date-time-functions/makedate", - "sql-manual/sql-functions/date-time-functions/dayofweek", + "sql-manual/sql-functions/date-time-functions/str_to_date", + "sql-manual/sql-functions/date-time-functions/time_round", + "sql-manual/sql-functions/date-time-functions/timediff", "sql-manual/sql-functions/date-time-functions/timestampadd", - "sql-manual/sql-functions/date-time-functions/from_days", - "sql-manual/sql-functions/date-time-functions/weekofyear", - "sql-manual/sql-functions/date-time-functions/year", "sql-manual/sql-functions/date-time-functions/timestampdiff", - "sql-manual/sql-functions/date-time-functions/dayofmonth", - "sql-manual/sql-functions/date-time-functions/dayofyear", - "sql-manual/sql-functions/date-time-functions/date_format", "sql-manual/sql-functions/date-time-functions/date_add", + "sql-manual/sql-functions/date-time-functions/date_sub", + "sql-manual/sql-functions/date-time-functions/date_format", + "sql-manual/sql-functions/date-time-functions/datediff", "sql-manual/sql-functions/date-time-functions/minutes_add", + "sql-manual/sql-functions/date-time-functions/minutes_diff", "sql-manual/sql-functions/date-time-functions/minutes_sub", "sql-manual/sql-functions/date-time-functions/seconds_add", + "sql-manual/sql-functions/date-time-functions/seconds_diff", "sql-manual/sql-functions/date-time-functions/seconds_sub", "sql-manual/sql-functions/date-time-functions/hours_add", + "sql-manual/sql-functions/date-time-functions/hours_diff", "sql-manual/sql-functions/date-time-functions/hours_sub", "sql-manual/sql-functions/date-time-functions/days_add", + "sql-manual/sql-functions/date-time-functions/days_diff", "sql-manual/sql-functions/date-time-functions/days_sub", "sql-manual/sql-functions/date-time-functions/weeks_add", + "sql-manual/sql-functions/date-time-functions/weeks_diff", "sql-manual/sql-functions/date-time-functions/weeks_sub", "sql-manual/sql-functions/date-time-functions/months_add", + "sql-manual/sql-functions/date-time-functions/months_diff", "sql-manual/sql-functions/date-time-functions/months_sub", "sql-manual/sql-functions/date-time-functions/years_add", - "sql-manual/sql-functions/date-time-functions/years_sub", - "sql-manual/sql-functions/date-time-functions/curdate", - "sql-manual/sql-functions/date-time-functions/current_timestamp", - "sql-manual/sql-functions/date-time-functions/str_to_date", - "sql-manual/sql-functions/date-time-functions/weekday", - "sql-manual/sql-functions/date-time-functions/to_days", - "sql-manual/sql-functions/date-time-functions/datediff", - "sql-manual/sql-functions/date-time-functions/now", - "sql-manual/sql-functions/date-time-functions/time_round", - "sql-manual/sql-functions/date-time-functions/utc_timestamp", - "sql-manual/sql-functions/date-time-functions/convert_tz", - "sql-manual/sql-functions/date-time-functions/second" + "sql-manual/sql-functions/date-time-functions/years_diff", + "sql-manual/sql-functions/date-time-functions/years_sub" ] }, { diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/days_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/days_diff.md new file mode 100644 index 00000000000000..f3780983685a9e --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/days_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "days_diff", + "language": "zh-CN" +} +--- + + + +## days_diff +### description +#### Syntax + +`INT days_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几天 + +### example + +``` +mysql> select days_diff('2020-12-25 22:00:00','2020-12-24 22:00:00'); ++---------------------------------------------------------+ +| days_diff('2020-12-25 22:00:00', '2020-12-24 22:00:00') | ++---------------------------------------------------------+ +| 1 | ++---------------------------------------------------------+ +``` + +### keywords + + days_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/extract.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/extract.md new file mode 100644 index 00000000000000..e045b035cf3205 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/extract.md @@ -0,0 +1,53 @@ +--- +{ + "title": "extract", + "language": "zh-CN" +} +--- + + + +## extract +### description +#### Syntax + +`INT extract(unit FROM DATETIME)` + +提取DATETIME某个指定单位的值。单位可以为year, month, day, hour, minute或者second + +### Example + +``` +mysql> select extract(year from '2022-09-22 17:01:30') as year, + -> extract(month from '2022-09-22 17:01:30') as month, + -> extract(day from '2022-09-22 17:01:30') as day, + -> extract(hour from '2022-09-22 17:01:30') as hour, + -> extract(minute from '2022-09-22 17:01:30') as minute, + -> extract(second from '2022-09-22 17:01:30') as second; ++------+-------+------+------+--------+--------+ +| year | month | day | hour | minute | second | ++------+-------+------+------+--------+--------+ +| 2022 | 9 | 22 | 17 | 1 | 30 | ++------+-------+------+------+--------+--------+ +``` + +### keywords + + extract diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md new file mode 100644 index 00000000000000..27bf4a80ef5ecf --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/hours_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "hours_diff", + "language": "zh-CN" +} +--- + + + +## hours_diff +### description +#### Syntax + +`INT hours_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几小时 + +### example + +``` +mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++----------------------------------------------------------+ +| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++----------------------------------------------------------+ +| 1 | ++----------------------------------------------------------+ +``` + +### keywords + + hours_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/localtime.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/localtime.md new file mode 100644 index 00000000000000..fd943395df7759 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/localtime.md @@ -0,0 +1,56 @@ +--- +{ + "title": "localtime,localtimestamp", + "language": "zh-CN" +} +--- + + + +## localtime,localtimestamp +### description +#### Syntax + +`DATETIME localtime()` +`DATETIME localtimestamp()` + +获得当前的时间,以Datetime类型返回 + +### Example + +``` +mysql> select localtime(); ++---------------------+ +| localtime() | ++---------------------+ +| 2022-09-22 17:30:23 | ++---------------------+ + +mysql> select localtimestamp(); ++---------------------+ +| localtimestamp() | ++---------------------+ +| 2022-09-22 17:30:29 | ++---------------------+ +``` + +### keywords + + localtime,localtimestamp diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md new file mode 100644 index 00000000000000..e1fd51d582cc17 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/minutes_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "minutes_diff", + "language": "zh-CN" +} +--- + + + +## minutes_diff +### description +#### Syntax + +`INT minutes_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几分钟 + +### example + +``` +mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++------------------------------------------------------------+ +| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++------------------------------------------------------------+ +| 60 | ++------------------------------------------------------------+ +``` + +### keywords + + minutes_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/months_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/months_diff.md new file mode 100644 index 00000000000000..5cb02f2830360b --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/months_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "months_diff", + "language": "zh-CN" +} +--- + + + +## months_diff +### description +#### Syntax + +`INT months_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几个月 + +### example + +``` +mysql> select months_diff('2020-12-25','2020-10-25'); ++-----------------------------------------------------------+ +| months_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | ++-----------------------------------------------------------+ +| 2 | ++-----------------------------------------------------------+ +``` + +### keywords + + months_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/quarter.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/quarter.md new file mode 100644 index 00000000000000..d0d96a0cfe0d13 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/quarter.md @@ -0,0 +1,48 @@ +--- +{ + "title": "quarter", + "language": "zh-CN" +} +--- + + + +## quarter +### description +#### Syntax + +`INT quarter(DATETIME date)` + +返回指定的日期所属季度,以INT类型返回 + +### Example + +``` +mysql> select quarter('2022-09-22 17:00:00'); ++--------------------------------+ +| quarter('2022-09-22 17:00:00') | ++--------------------------------+ +| 3 | ++--------------------------------+ +``` + +### keywords + + quarter diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md new file mode 100644 index 00000000000000..54c0c24fc9c9d4 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/seconds_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "seconds_diff", + "language": "zh-CN" +} +--- + + + +## seconds_diff +### description +#### Syntax + +`INT seconds_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几秒 + +### example + +``` +mysql> select seconds_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); ++------------------------------------------------------------+ +| seconds_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | ++------------------------------------------------------------+ +| 3600 | ++------------------------------------------------------------+ +``` + +### keywords + + seconds_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md new file mode 100644 index 00000000000000..8accec3cea1bf4 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/weeks_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "weeks_diff", + "language": "zh-CN" +} +--- + + + +## weeks_diff +### description +#### Syntax + +`INT weeks_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几星期 + +### example + +``` +mysql> select weeks_diff('2020-12-25','2020-10-25'); ++----------------------------------------------------------+ +| weeks_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') | ++----------------------------------------------------------+ +| 8 | ++----------------------------------------------------------+ +``` + +### keywords + + weeks_diff diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/year_floor.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/year_floor.md new file mode 100644 index 00000000000000..df7d6851bd6ac7 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/year_floor.md @@ -0,0 +1,48 @@ +--- +{ + "title": "year_floor", + "language": "zh-CN" +} +--- + + + +## year_floor +### description +#### Syntax + +`DATETIME year_floor(DATETIME date)` + +指定时间向下舍入,保留字段级别到年,返回DATETIME类型 + +### Example + +``` +mysql> select year_floor('2022-09-22 17:00:00'); ++-----------------------------------+ +| year_floor('2022-09-22 17:00:00') | ++-----------------------------------+ +| 2022-01-01 00:00:00 | ++-----------------------------------+ +``` + +### keywords + + year_floor diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/years_diff.md b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/years_diff.md new file mode 100644 index 00000000000000..604c6723add1d4 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/date-time-functions/years_diff.md @@ -0,0 +1,48 @@ +--- +{ + "title": "years_diff", + "language": "zh-CN" +} +--- + + + +## years_diff +### description +#### Syntax + +`INT years_diff(DATETIME enddate, DATETIME startdate)` + +开始时间到结束时间相差几年 + +### example + +``` +mysql> select years_diff('2020-12-25','2019-10-25'); ++----------------------------------------------------------+ +| years_diff('2020-12-25 00:00:00', '2019-10-25 00:00:00') | ++----------------------------------------------------------+ +| 1 | ++----------------------------------------------------------+ +``` + +### keywords + + years_diff