-
Notifications
You must be signed in to change notification settings - Fork 403
fix the document of TO_DATE, TO_DAYS, year_floor, WEEKS_ADD, WEEKS_DIFF, WEEKS_SUB function #2197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
da56cc1
01a9448
2a237e7
a3ad28d
c8211a0
646455e
a9231e3
ecc1042
eae380b
188b8ff
bb0a4e5
3e4fd40
084ac46
8c9d6b0
d9ee9aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,27 +24,45 @@ specific language governing permissions and limitations | |
| under the License. | ||
| --> | ||
|
|
||
| ## to_days | ||
| ### Description | ||
| #### Syntax | ||
|
|
||
| `INT TO DAYS` | ||
| ## Description | ||
| Date calculation function, which is used to convert a date into a day value, that is, to calculate the total number of days from December 31, 0 AD (the base date) to the specified date. | ||
|
|
||
| ## Syntax | ||
|
|
||
| Days of returning date distance 0000-01-01 | ||
| ```sql | ||
| TO_DAYS([<datetime_value> | <date_value>]) | ||
|
||
| ``` | ||
|
|
||
| ## Optional parameters | ||
| 1. **<datetime_value>** | ||
| > datetime type datetime | ||
|
|
||
| 2. **<date_value>** | ||
| > date type datetime | ||
|
|
||
| The parameter is Date or Datetime type | ||
|
|
||
| ### example | ||
| ## Example | ||
|
|
||
| Query how many days are there since October 7, 2007 | ||
| ```sql | ||
| select to_days('2007-10-07'); | ||
| ``` | ||
| mysql> select to_days('2007-10-07'); | ||
| +-----------------------+ | ||
| | to_days('2007-10-07') | | ||
| +-----------------------+ | ||
| | 733321 | | ||
| +-----------------------+ | ||
| ```text | ||
| +---------------------------------------+ | ||
| | to_days(cast('2007-10-07' as DATEV2)) | | ||
| +---------------------------------------+ | ||
| | 733321 | | ||
| +---------------------------------------+ | ||
| ``` | ||
|
|
||
| ### keywords | ||
| TO_DAYS,TO,DAYS | ||
| ```sql | ||
| select to_days('2007-10-07 10:03:09'); | ||
| ``` | ||
| ```text | ||
| +------------------------------------------------+ | ||
| | to_days(cast('2007-10-07 10:03:09' as DATEV2)) | | ||
| +------------------------------------------------+ | ||
| | 733321 | | ||
| +------------------------------------------------+ | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,27 +24,63 @@ specific language governing permissions and limitations | |
| under the License. | ||
| --> | ||
|
|
||
| ## weeks_add | ||
| ### description | ||
| #### Syntax | ||
| ## Description | ||
| This function is used to add (or subtract) a certain number of weeks from a specified date or time value. | ||
|
|
||
| `DATETIME WEEKS_ADD(DATETIME date, INT weeks)` | ||
| ## Syntax | ||
|
|
||
| ADD a specified number of weeks from a datetime or date | ||
| ```sql | ||
| WEEKS_ADD([<date_value> | <datetime_value>], <weeks_value>) | ||
|
||
| ``` | ||
|
|
||
| The parameter date can be DATETIME or DATE, and the return type is consistent with that of the parameter date. | ||
| ## Required parameters | ||
| **<weeks_value>** | ||
| > Integer, indicating the number of weeks to increase or decrease (positive number indicates increase, negative number indicates decrease) | ||
|
|
||
| ### example | ||
| ## Optional parameters | ||
| - **<date_value>** | ||
| > `DATE` date type input value | ||
|
|
||
| ``` | ||
| mysql> select weeks_add("2020-02-02 02:02:02", 1); | ||
| +-------------------------------------+ | ||
| | weeks_add('2020-02-02 02:02:02', 1) | | ||
| +-------------------------------------+ | ||
| | 2020-02-09 02:02:02 | | ||
| +-------------------------------------+ | ||
| ``` | ||
| - **<datetime_value>** | ||
| > `DATETIME` time type input value | ||
|
|
||
| ## example | ||
|
|
||
|
|
||
| 1. Add one week to the time `2020-02-02 02:02:02` | ||
| ```sql | ||
| select weeks_add("2020-02-02 02:02:02", 1); | ||
| ``` | ||
| ```text | ||
| +-------------------------------------+ | ||
| | weeks_add('2020-02-02 02:02:02', 1) | | ||
| +-------------------------------------+ | ||
| | 2020-02-09 02:02:02 | | ||
| +-------------------------------------+ | ||
| ``` | ||
|
|
||
| 2. Subtract one week from the time `2020-02-02 02:02:02` | ||
| ```sql | ||
| select weeks_add("2020-02-02 02:02:02", -1); | ||
| ``` | ||
| ```text | ||
| +-------------------------------------------------------------+ | ||
| | weeks_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), -1) | | ||
| +-------------------------------------------------------------+ | ||
| | 2020-01-26 02:02:02 | | ||
| +-------------------------------------------------------------+ | ||
| ``` | ||
|
|
||
| 3. Add one week to the date `2020-02-02` | ||
| ```sql | ||
| select weeks_add("2020-02-02", 1); | ||
| ``` | ||
| ```text | ||
| +--------------------------------------------+ | ||
| | weeks_add(cast('2020-02-02' as DATEV2), 1) | | ||
| +--------------------------------------------+ | ||
| | 2020-02-09 | | ||
| +--------------------------------------------+ | ||
| ``` | ||
|
|
||
| ### keywords | ||
|
|
||
| WEEKS_ADD | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,25 +24,58 @@ specific language governing permissions and limitations | |||||
| under the License. | ||||||
| --> | ||||||
|
|
||||||
| ## weeks_diff | ||||||
| ### description | ||||||
| #### Syntax | ||||||
| ## Description | ||||||
| Calculates the number of complete weeks (in 7-day units) between two date or time values. | ||||||
|
|
||||||
| `INT weeks_diff(DATETIME enddate, DATETIME startdate)` | ||||||
| ## Syntax | ||||||
|
|
||||||
| The difference between the start time and the end time is weeks | ||||||
| ```sql | ||||||
| WEEKS_DIFF([<end_date> | <end_datetime>], [<start_date> | <start_datetime>]) | ||||||
|
||||||
| WEEKS_DIFF([<end_date> | <end_datetime>], [<start_date> | <start_datetime>]) | |
| WEEKS_DIFF(<end_date> <start_date>) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## Optional parameters | |
| ## Parameters |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这里解释一下可以处理 date / datetime 就可以了
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,27 +24,47 @@ specific language governing permissions and limitations | |||||
| under the License. | ||||||
| --> | ||||||
|
|
||||||
| ## weeks_sub | ||||||
| ### description | ||||||
| #### Syntax | ||||||
|
|
||||||
| `DATETIME WEEKS_SUB(DATETIME date, INT weeks)` | ||||||
| ## Description | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缺少函数描述 |
||||||
| ## Syntax | ||||||
| ```sql | ||||||
| WEEKS_SUB([<date_value> | <datetime_value>], <week_period>) | ||||||
|
||||||
| WEEKS_SUB([<date_value> | <datetime_value>], <week_period>) | |
| WEEKS_SUB(<date_value>, <week_period>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用表格
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function doc's parameter should put into a table.