Skip to content

Commit

Permalink
add doc of now() and sysdate() (#1042)
Browse files Browse the repository at this point in the history
* add doc of now() and sysdate()

* fix
  • Loading branch information
yangj1211 authored Apr 30, 2024
1 parent 414f09b commit 889a81b
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
56 changes: 56 additions & 0 deletions docs/MatrixOne/Reference/Functions-and-Operators/Datetime/now.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# NOW()

## 函数说明

`NOW()` 函数返回当前日期和时间的 'YYYY-MM-DD HH:MM:SS' 格式的值。

`NOW()` 返回语句开始执行的时间。这与 [`SYSDATE()`](sysdate.md) 的行为不同,后者返回执行过程中动态的实时时间。

## 函数语法

```
> NOW(fsp)
```

## 参数释义

| 参数 | 说明 |
| ---- | ---- |
| fsp | 非必要参数。如果给定 fsp 参数以指定从 0 到 6 的小数秒精度,则返回值包括该数字的小数秒部分。|

## 示例

```sql
mysql> select now();
+----------------------------+
| now() |
+----------------------------+
| 2024-04-29 08:03:50.479238 |
+----------------------------+
1 row in set (0.03 sec)

mysql> select now(6);
+----------------------------+
| now(6) |
+----------------------------+
| 2024-04-29 08:05:26.528629 |
+----------------------------+
1 row in set (0.02 sec)

mysql> SELECT NOW(), SLEEP(2), NOW();
+----------------------------+----------+----------------------------+
| now() | sleep(2) | now() |
+----------------------------+----------+----------------------------+
| 2024-04-29 08:17:23.876546 | 0 | 2024-04-29 08:17:23.876546 |
+----------------------------+----------+----------------------------+
1 row in set (2.06 sec)

mysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();
+----------------------------+----------+----------------------------+
| sysdate() | sleep(2) | sysdate() |
+----------------------------+----------+----------------------------+
| 2024-04-29 16:19:21.439725 | 0 | 2024-04-29 16:19:23.440187 |
+----------------------------+----------+----------------------------+
1 row in set (2.01 sec)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SYSDATE()

## 函数说明

`SYSDATE()` 函数返回当前日期和时间的 'YYYY-MM-DD HH:MM:SS' 格式的值。

`SYSDATE()` 返回执行过程中动态的实时时间。这与 [`NOW()`](now.md) 的行为不同,后者返回语句开始执行的时间。

## 函数语法

```
> SYSDATE(fsp)
```

## 参数释义

| 参数 | 说明 |
| ---- | ---- |
| fsp | 非必要参数。如果给定 fsp 参数以指定从 0 到 6 的小数秒精度,则返回值包括该数字的小数秒部分。|

## 示例

```sql
mysql> select sysdate();
+----------------------------+
| sysdate() |
+----------------------------+
| 2024-04-30 10:49:39.554807 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select sysdate(6);
+----------------------------+
| sysdate(6) |
+----------------------------+
| 2024-04-30 10:50:08.452370 |
+----------------------------+
1 row in set (0.00 sec)

mysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();
+----------------------------+----------+----------------------------+
| sysdate() | sleep(2) | sysdate() |
+----------------------------+----------+----------------------------+
| 2024-04-30 10:50:30.004912 | 0 | 2024-04-30 10:50:32.005203 |
+----------------------------+----------+----------------------------+
1 row in set (2.00 sec)

mysql> SELECT NOW(), SLEEP(2), NOW();
+----------------------------+----------+----------------------------+
| now() | sleep(2) | now() |
+----------------------------+----------+----------------------------+
| 2024-04-30 10:50:47.904309 | 0 | 2024-04-30 10:50:47.904309 |
+----------------------------+----------+----------------------------+
1 row in set (2.00 sec)

```
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
| [FROM_UNIXTIME()](./Datetime/from-unixtime.md) |把内部 UNIX 时间戳值转换为普通格式的日期时间值,以 YYYY-MM-DD HH:MM:SS 或 YYYYMMDDHHMMSS 格式来显示|
| [MINUTE()](./Datetime/minute.md) |返回时间参数的分钟|
| [MONTH()](./Datetime/month.md) |返回日期参数的月份|
| [NOW()](./Datetime/now.md) |返回当前日期和时间的 'YYYY-MM-DD HH:MM:SS' 格式的值。|
| [SECOND()](./Datetime/second.md) |返回时间参数的秒数|
| [STR_TO_DATE()](./Datetime/str-to-date.md) |按照指定日期或时间显示格式,将字符串转换为日期或日期时间类型|
| [STR_TO_DATE()](./Datetime/str-to-date.md) |按照指定日期或时间显示格式,将字符串转换为日期或日期时间类型|
| [SYSDATE()](./Datetime/sysdate.md) |返回当前日期和时间的 'YYYY-MM-DD HH:MM:SS' 格式的值。|
| [TIME()](./Datetime/time.md) |提取时间或日期时间的时间部分并将其作为字符串返回|
| [TIMEDIFF()](./Datetime/timediff.md) |返回两个时间参数之间的差值|
| [TIMESTAMP()](./Datetime/timestamp.md) |将日期或日期时间参数作为日期时间值返回|
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,10 @@ nav:
- FROM_UNIXTIME: MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime.md
- MINUTE(): MatrixOne/Reference/Functions-and-Operators/Datetime/minute.md
- MONTH(): MatrixOne/Reference/Functions-and-Operators/Datetime/month.md
- NOW(): MatrixOne/Reference/Functions-and-Operators/Datetime/now.md
- SECOND(): MatrixOne/Reference/Functions-and-Operators/Datetime/second.md
- STR_TO_DATE(): MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date.md
- SYSDATE(): MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate.md
- TIME(): MatrixOne/Reference/Functions-and-Operators/Datetime/time.md
- TIMEDIFF(): MatrixOne/Reference/Functions-and-Operators/Datetime/timediff.md
- TIMESTAMP(): MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp.md
Expand Down

0 comments on commit 889a81b

Please sign in to comment.