Skip to content

Commit

Permalink
add example of time type (#1882)
Browse files Browse the repository at this point in the history
* add example of time type

* Update docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md

* Update docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md

* Update docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md

* Update docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md

* Update docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md

Co-authored-by: randomJoe211 <[email protected]>
  • Loading branch information
cooper-lzy and randomJoe211 authored Jan 17, 2023
1 parent d092af9 commit 09bc9c4
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,18 @@ The `DURATION` data type is used to indicate a period of time. Map data that are
nebula> INSERT VERTEX date1(p1, p2, p3) VALUES "test1":(date("2021-03-17"), time("17:53:59"), datetime("2017-03-04T22:30:40.003000[Asia/Shanghai]"));
```
3. Return the content of the property `p1` on `test1`.
3. Query whether the value of property `p1` on the `test1` tag is `2021-03-17`.
```ngql
nebula> MATCH (v:date1) RETURN v.date1.p1 == date("2021-03-17");
+----------------------------------+
| (v.date1.p1==date("2021-03-17")) |
+----------------------------------+
| true |
+----------------------------------+
```
4. Return the content of the property `p1` on `test1`.
```ngql
nebula> CREATE TAG INDEX IF NOT EXISTS date1_index ON date1(p1);
Expand All @@ -170,13 +181,26 @@ The `DURATION` data type is used to indicate a period of time. Map data that are
+------------------+
```
4. Create a tag named `school` with the property of `TIMESTAMP`.
5. Search for vertices with `p3` property values less than `2023-01-01T00:00:00.000000`, and return the `p3` values.
```ngql
nebula> MATCH (v:date1) \
WHERE v.date1.p3 < datetime("2023-01-01T00:00:00.000000") \
RETURN v.date1.p3;
+----------------------------+
| v.date1.p3 |
+----------------------------+
| 2017-03-04T14:30:40.003000 |
+----------------------------+
```
6. Create a tag named `school` with the property of `TIMESTAMP`.
```ngql
nebula> CREATE TAG IF NOT EXISTS school(name string , found_time timestamp);
```
5. Insert a vertex named `DUT` with a found-time timestamp of `"1988-03-01T08:00:00"`.
7. Insert a vertex named `DUT` with a found-time timestamp of `"1988-03-01T08:00:00"`.
```ngql
# Insert as a timestamp. The corresponding timestamp of 1988-03-01T08:00:00 is 573177600, or 573206400 UTC.
Expand All @@ -186,7 +210,7 @@ The `DURATION` data type is used to indicate a period of time. Map data that are
nebula> INSERT VERTEX school(name, found_time) VALUES "DUT":("DUT", timestamp("1988-03-01T08:00:00"));
```
6. Insert a vertex named `dut` and store time with `now()` or `timestamp()` functions.
8. Insert a vertex named `dut` and store time with `now()` or `timestamp()` functions.
```ngql
# Use now() function to store time
Expand Down

0 comments on commit 09bc9c4

Please sign in to comment.