diff --git a/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md b/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md index 522bf0043d0..ef6e2970401 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md +++ b/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md @@ -16,6 +16,10 @@ This topic will describe the `DATE`, `TIME`, `DATETIME`, `TIMESTAMP`, and `DURAT - `date()`, `time()`, and `datetime()` all accept the property name to return a specific property value of itself. For example, `date().month` returns the current month, while `time("02:59:40").minute` returns the minutes of the importing time. +- For time operations it is recommended to use `duration()` to calculate the offset of the moment. Addition and subtraction of `date()` and `date()`, `timestamp()` and `timestamp()` are also supported. + +- When setting the year of the time as a negative number, you need to use Map type data. + ## OpenCypher Compatibility In nGQL: @@ -32,7 +36,31 @@ In nGQL: The `DATE` type is used for values with a date part but no time part. Nebula Graph retrieves and displays `DATE` values in the `YYYY-MM-DD` format. The supported range is `-32768-01-01` to `32767-12-31`. -The properties of `date()` include `year`, `month`, and `day`. +The properties of `date()` include `year`, `month`, and `day`. `date()` supports the input of `YYYYY`, `YYYYY-MM` or `YYYYY-MM-DD`, and defaults to `01` for an untyped month or day. + +```ngql +nebula> RETURN DATE({year:-123, month:12, day:3}); ++------------------------------------+ +| date({year:-(123),month:12,day:3}) | ++------------------------------------+ +| -123-12-03 | ++------------------------------------+ + +nebula> RETURN DATE("23333"); ++---------------+ +| date("23333") | ++---------------+ +| 23333-01-01 | ++---------------+ + +nebula> RETURN DATE("2023-12-12") - DATE("2023-12-11"); ++-----------------------------------------+ +| (date("2023-12-12")-date("2023-12-11")) | ++-----------------------------------------+ +| 1 | ++-----------------------------------------+ +``` + ## TIME diff --git a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md index b1538ef0327..10a31c975f5 100644 --- a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md +++ b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md @@ -4,19 +4,12 @@ NebulaGraph supports the following comparison operators. | Name | Description | | :---- | :----: | -| `=` | Assigns a value | -| `+` | Addition operator | -| `-` | Minus operator | -| `*` | Multiplication operator | -| `/` | Division operator | | `==` | Equal operator | | `!=`, `<>` | Not equal operator | | `>` | Greater than operator | | `>=` | Greater than or equal operator | | `<` | Less than operator | | `<=` | Less than or equal operator | -| `%` | Modulo operator | -| `-` | Changes the sign of the argument | | `IS NULL` | NULL check | | `IS NOT NULL` | Not NULL check | | `IS EMPTY` | EMPTY check | diff --git a/docs-2.0/3.ngql-guide/5.operators/10.arithmetic.md b/docs-2.0/3.ngql-guide/5.operators/10.arithmetic.md new file mode 100644 index 00000000000..b3266727ab3 --- /dev/null +++ b/docs-2.0/3.ngql-guide/5.operators/10.arithmetic.md @@ -0,0 +1,37 @@ +# Arithmetic operators + +NebulaGraph supports the following arithmetic operators. + +| Name | Description | +| :---- | :----: | +| `+` | Addition operator | +| `-` | Minus operator | +| `*` | Multiplication operator | +| `/` | Division operator | +| `%` | Modulo operator | +| `-` | Changes the sign of the argument | + +## Examples + +```ngql +nebula> RETURN 1+2 AS result; ++--------+ +| result | ++--------+ +| 3 | ++--------+ + +nebula> RETURN -10+5 AS result; ++--------+ +| result | ++--------+ +| -5 | ++--------+ + +nebula> RETURN (3*8)%5 AS result; ++--------+ +| result | ++--------+ +| 4 | ++--------+ +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index a0bcfdb8c57..338aa28fb1b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -337,6 +337,7 @@ nav: - Set: 3.ngql-guide/5.operators/6.set.md - String: 3.ngql-guide/5.operators/7.string.md - List: 3.ngql-guide/5.operators/8.list.md + - Arithmetic: 3.ngql-guide/5.operators/10.arithmetic.md - Precedence: 3.ngql-guide/5.operators/9.precedence.md - Functions and expressions: