From 31ba236fd30811b4b24ae08d68c5b9ffbb616575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Wed, 19 Feb 2025 11:35:37 +0100 Subject: [PATCH 1/5] add examples --- .../ROOT/pages/values-and-types/temporal.adoc | 581 +++++++++++++++--- 1 file changed, 492 insertions(+), 89 deletions(-) diff --git a/modules/ROOT/pages/values-and-types/temporal.adoc b/modules/ROOT/pages/values-and-types/temporal.adoc index 9d7fd4a25..828677775 100644 --- a/modules/ROOT/pages/values-and-types/temporal.adoc +++ b/modules/ROOT/pages/values-and-types/temporal.adoc @@ -511,145 +511,399 @@ For more information, see the xref::values-and-types/temporal.adoc#cypher-tempor [[cypher-temporal-specify-instant-examples]] === Examples -Below are examples of parsing instant values using various temporal functions. -More information about these temporal functions can be found xref::functions/temporal/index.adoc[here]. +In order to create or parse a temporal instant type, its corresponding xref:functions/temporal/index.adoc[function] must be used. +For example, in order to create a property value of type `ZONED DATETIME`, the xref:functions/temporal/index.adoc#functions-datetime[`datetime()`] function must be used. -.+datetime+ -====== +This section provides examples of how to create properties with different temporal value types and how to parse temporal instant values. +For specific examples, see: -Parsing a `ZONED DATETIME` using the _calendar date_ format: -.Query +* xref:values-and-types/temporal.adoc#examples-date[`DATE`] +* xref:values-and-types/temporal.adoc#examples-localtime[`LOCAL TIME`] +* xref:values-and-types/temporal.adoc#examples-zonedtime[`ZONED TIME`] +* xref:values-and-types/temporal.adoc#examples-local-datetime[`LOCAL DATETIME`] +* xref:values-and-types/temporal.adoc#examples-zoned-datetime[`ZONED DATETIME`] +* xref:values-and-types/temporal.adoc#examples-truncate[Truncating temporal values] + +[[examples-date]] +==== `DATE` + +To work with `DATE` values, including creating, parsing, and extracting components, use the xref:functions/temporal/index.adoc#functions-date[`date()`] function. + +.`DATE` +====== + +.Create a `DATE` property value [source, cypher] ---- -RETURN datetime('2015-06-24T12:50:35.556+0100') AS theDateTime +CREATE (n:Label) +SET n.date = date("2025-02-18") +RETURN n.date AS date, valueType(n.date) AS temporalValueType ---- .Result -[role="queryresult",options="header,footer",cols="1* Date: Wed, 19 Feb 2025 11:45:06 +0100 Subject: [PATCH 2/5] reword --- modules/ROOT/pages/values-and-types/temporal.adoc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/ROOT/pages/values-and-types/temporal.adoc b/modules/ROOT/pages/values-and-types/temporal.adoc index 828677775..ca345e6cc 100644 --- a/modules/ROOT/pages/values-and-types/temporal.adoc +++ b/modules/ROOT/pages/values-and-types/temporal.adoc @@ -511,13 +511,11 @@ For more information, see the xref::values-and-types/temporal.adoc#cypher-tempor [[cypher-temporal-specify-instant-examples]] === Examples -In order to create or parse a temporal instant type, its corresponding xref:functions/temporal/index.adoc[function] must be used. +To work with a particular temporal instant type, its corresponding xref:functions/temporal/index.adoc[function] must be used. For example, in order to create a property value of type `ZONED DATETIME`, the xref:functions/temporal/index.adoc#functions-datetime[`datetime()`] function must be used. -This section provides examples of how to create properties with different temporal value types and how to parse temporal instant values. For specific examples, see: - * xref:values-and-types/temporal.adoc#examples-date[`DATE`] * xref:values-and-types/temporal.adoc#examples-localtime[`LOCAL TIME`] * xref:values-and-types/temporal.adoc#examples-zonedtime[`ZONED TIME`] @@ -548,7 +546,7 @@ RETURN n.date AS date, valueType(n.date) AS temporalValueType | 2025-02-18 | "DATE NOT NULL" -1+d|Rows: 1 +2+d|Rows: 1 |=== .Create a `DATE` property value using components @@ -566,7 +564,7 @@ RETURN n.date AS date, valueType(n.date) AS temporalValueType | 2025-02-18 | "DATE NOT NULL" -1+d|Rows: 1 +2+d|Rows: 1 |=== .Parse a `DATE` using the week date format: @@ -973,6 +971,8 @@ RETURN d.timezone, d.offset, d.offsetMinutes, d.epochSeconds, d.epochMillis [[examples-truncate]] ==== Truncating temporal values +The truncate functions in Neo4j allow you to reduce the precision of temporal values by truncating them to a specified component such as `year`, `month`, or `second`. + .Truncate `DATE` values ====== @@ -982,13 +982,13 @@ To truncate `DATE` values, use the xref:functions/temporal/index.adoc#functions- .Get the first day of the current year: [source, cypher, role=test-result-skip] ---- -RETURN date.truncate('year') AS day +RETURN date.truncate('year') AS firstDay ---- .Result [role="queryresult",options="header,footer",cols="1* Date: Wed, 19 Feb 2025 13:02:57 +0100 Subject: [PATCH 3/5] fix query --- modules/ROOT/pages/values-and-types/temporal.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/values-and-types/temporal.adoc b/modules/ROOT/pages/values-and-types/temporal.adoc index ca345e6cc..262789524 100644 --- a/modules/ROOT/pages/values-and-types/temporal.adoc +++ b/modules/ROOT/pages/values-and-types/temporal.adoc @@ -636,7 +636,7 @@ RETURN n.localTime AS localTime, valueType(n.localTime) AS temporalValueType ---- CREATE (n:Label) SET n.localTime = localtime({hour: 12, minute: 34, second: 56, millisecond: 789}) -RETURN n.localTime AS localTime, valueType(n.localtime) AS temporalValueType +RETURN n.localTime AS localTime, valueType(n.localTime) AS temporalValueType ---- .Result From 6fc055837f14e6d5626dfff11accb9d2f58275d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:11:29 +0100 Subject: [PATCH 4/5] more query fixed --- modules/ROOT/pages/values-and-types/temporal.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ROOT/pages/values-and-types/temporal.adoc b/modules/ROOT/pages/values-and-types/temporal.adoc index 262789524..26113bf3a 100644 --- a/modules/ROOT/pages/values-and-types/temporal.adoc +++ b/modules/ROOT/pages/values-and-types/temporal.adoc @@ -683,7 +683,7 @@ To work with `ZONED TIME` values, including creating, parsing, and extracting co ---- CREATE (n:Label) SET n.zonedTime = time("12:34:56.789+02:00") -RETURN n.zonedTime AS zonedTime, valueType(n.time) AS temporalValueType +RETURN n.zonedTime AS zonedTime, valueType(n.zonedTime) AS temporalValueType ---- .Result @@ -701,8 +701,8 @@ RETURN n.zonedTime AS zonedTime, valueType(n.time) AS temporalValueType [source, cypher] ---- CREATE (n:Label) -SET n.time = time({hour: 12, minute: 34, second: 56, millisecond: 789, timezone: 'Europe/Stockholm'}) -RETURN n.time AS time, valueType(n.time) AS temporalValueType +SET n.zonedTime = time({hour: 12, minute: 34, second: 56, millisecond: 789, timezone: 'Europe/Stockholm'}) +RETURN n.zonedTime AS zonedTime, valueType(zonedTime) AS temporalValueType ---- .Result @@ -834,7 +834,7 @@ To work with `ZONED DATETIME` values, including creating, parsing, and extractin ---- CREATE (n:Label) SET n.zonedDatetime = datetime("2025-02-18T12:34:56.789+02:00") -RETURN n.zonedDateTime AS zonedDatetTime, valueType(n.zonedDateTime) AS temporalValueType +RETURN n.zonedDateTime AS zonedDateTime, valueType(n.zonedDateTime) AS temporalValueType ---- .Result From 680f231ff7a1815ea62143eedaa8db3a9fd6882d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:23:02 +0100 Subject: [PATCH 5/5] more fixes --- modules/ROOT/pages/values-and-types/temporal.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ROOT/pages/values-and-types/temporal.adoc b/modules/ROOT/pages/values-and-types/temporal.adoc index 26113bf3a..106107711 100644 --- a/modules/ROOT/pages/values-and-types/temporal.adoc +++ b/modules/ROOT/pages/values-and-types/temporal.adoc @@ -702,7 +702,7 @@ RETURN n.zonedTime AS zonedTime, valueType(n.zonedTime) AS temporalValueType ---- CREATE (n:Label) SET n.zonedTime = time({hour: 12, minute: 34, second: 56, millisecond: 789, timezone: 'Europe/Stockholm'}) -RETURN n.zonedTime AS zonedTime, valueType(zonedTime) AS temporalValueType +RETURN n.zonedTime AS zonedTime, valueType(n.zonedTime) AS temporalValueType ---- .Result @@ -833,7 +833,7 @@ To work with `ZONED DATETIME` values, including creating, parsing, and extractin [source, cypher, role=test-result-skip] ---- CREATE (n:Label) -SET n.zonedDatetime = datetime("2025-02-18T12:34:56.789+02:00") +SET n.zonedDateTime = datetime("2025-02-18T12:34:56.789+02:00") RETURN n.zonedDateTime AS zonedDateTime, valueType(n.zonedDateTime) AS temporalValueType ---- @@ -871,7 +871,7 @@ RETURN n.zonedDateTime, valueType(n.zonedDateTime) AS temporalValueType ---- CREATE (n:Label) SET n.zonedDateTime = datetime({timezone: 'Europe/Stockholm'}) -RETURN n.zonedDateTime AS zonedDateTime, valueType(n.zonedDatetime) AS temporalValueType +RETURN n.zonedDateTime AS zonedDateTime, valueType(n.zonedDateTime) AS temporalValueType ---- .Result