Skip to content

Commit 0bec8e4

Browse files
rsill-neo4jLojjs
andauthored
Document temporal parsing (#1392)
Co-authored-by: Louise Berglund <[email protected]>
1 parent dabb537 commit 0bec8e4

File tree

3 files changed

+80
-30
lines changed

3 files changed

+80
-30
lines changed

modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,31 @@ Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+
2222
Features removed in Cypher 25 are still available on Neo4j 2025.06+ databases either by prepending a query with `CYPHER 5` or by having Cypher 5 as the default language for the database.
2323
For more information, see xref:queries/select-version.adoc[].
2424

25+
26+
[[cypher-deprecations-additions-removals-2025.10]]
27+
== Neo4j 2025.10
28+
29+
=== Updated in Cypher 25
30+
31+
[cols="2", options="header"]
32+
|===
33+
| Feature
34+
| Details
35+
36+
a|
37+
label:functionality[]
38+
label:updated[]
39+
[source, cypher, role="noheader"]
40+
----
41+
RETURN datetime('11/18/1986', "MM/dd/yyyy") AS dt
42+
----
43+
44+
| The following constructors of temporal types have been extended with the optional argument `pattern`:
45+
xref:functions/temporal/index.adoc#functions-date[date()], xref:functions/temporal/index.adoc#functions-datetime[datetime()], xref:functions/temporal/index.adoc#functions-localdatetime[localdatetime()], xref:functions/temporal/index.adoc#functions-localtime[localtime()], xref:functions/temporal/index.adoc#functions-time[time()] and xref:functions/temporal/duration.adoc#query-functions-temporal-duration[duration()].
46+
These patterns are the same as those used to create temporal strings with the xref:functions/temporal/format.adoc[`format()`] function introduced in 2025.09 and thus allow for the parsing of temporal strings into temporal values.
47+
|===
48+
49+
2550
[[cypher-deprecations-additions-removals-2025.09]]
2651
== Neo4j 2025.09
2752

modules/ROOT/pages/functions/temporal/duration.adoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@ See also xref::values-and-types/temporal.adoc[Temporal values] and xref::express
1616

1717
.Details
1818
|===
19-
| *Syntax* 3+| `duration(input)`
19+
| *Syntax* 3+| `duration(input[, pattern])`
2020
| *Description* 3+| Creates a `DURATION` value.
21-
.2+| *Arguments* | *Name* | *Type* | *Description*
22-
| `input` | `ANY` | A map optionally containing the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', or 'nanoseconds'.
21+
.3+| *Arguments* | *Name* | *Type* | *Description*
22+
| `input` | `ANY` | Either a string representation of a duration value or a map optionally containing the following keys: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', or 'nanoseconds'.
23+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
2324
| *Returns* 3+| `DURATION`
2425
|===
2526

2627
.Considerations
2728
|===
2829

29-
| At least one parameter must be provided (`duration()` and `+duration({})+` are invalid).
30-
| There is no constraint on how many of the parameters are provided.
30+
| If `input` is not a string, at least one component must be provided (`duration()` and `+duration({})+` are invalid).
31+
| There is no constraint on how many components are provided.
3132
| It is possible to have a `DURATION` where the amount of a smaller unit (e.g. `seconds`) exceeds the threshold of a larger unit (e.g. `days`).
32-
| The values of the parameters may be expressed as decimal fractions.
33-
| The values of the parameters may be arbitrarily large.
34-
| The values of the parameters may be negative.
33+
| The values of the components may be expressed as decimal fractions.
34+
| The values of components may be arbitrarily large.
35+
| The values of components may be negative.
3536
| The xref:values-and-types/temporal.adoc#cypher-temporal-accessing-components-durations[components of `DURATION` objects] are individually accessible.
37+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-duration-types-characters[Allowed characters for duration types].
3638

3739
|===
3840

@@ -85,7 +87,8 @@ duration("P14DT16H12M"),
8587
duration("P5M1.5D"),
8688
duration("P0.75M"),
8789
duration("PT0.75M"),
88-
duration("P2012-02-02T14:37:21.545")
90+
duration("P2012-02-02T14:37:21.545"),
91+
duration("5 hours 6 minutes", "h 'hours' m 'minutes'")
8992
] AS aDuration
9093
RETURN aDuration
9194
----
@@ -101,7 +104,8 @@ RETURN aDuration
101104
| P22DT19H51M49.5S
102105
| PT45S
103106
| P2012Y2M2DT14H37M21.545S
104-
1+d|Rows: 5
107+
| PT5H6M
108+
1+d|Rows: 6
105109
106110
|===
107111

modules/ROOT/pages/functions/temporal/index.adoc

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ The following table lists the supported truncation units and the corresponding s
332332

333333
.Details
334334
|===
335-
| *Syntax* 3+| `date( [input] )`
335+
| *Syntax* 3+| `date([ input, pattern] )`
336336
| *Description* 3+| Creates a `DATE` instant.
337-
.2+| *Arguments* | *Name* | *Type* | *Description*
337+
.3+| *Arguments* | *Name* | *Type* | *Description*
338338
| `input` | `ANY` | Either a string representation of a temporal value, a map containing the single key 'timezone', or a map containing temporal values ('date', 'year', 'month', 'day', 'week', 'dayOfWeek', 'quarter', 'dayOfQuarter', 'ordinalDay') as components.
339+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
339340
| *Returns* 3+| `DATE`
340341
|===
341342

343+
342344
.Temporal components
343345
[options="header"]
344346
|===
@@ -393,6 +395,7 @@ The following table lists the supported truncation units and the corresponding s
393395
| `date(null)` returns `null`.
394396
| If any of the optional parameters are provided, these will override the corresponding components of `date`.
395397
| `date(dd)` may be written instead of `+date({date: dd})+`.
398+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-instance-types-characters[Allowed characters for instance types].
396399

397400
|===
398401

@@ -604,7 +607,8 @@ date('2015-07'),
604607
date('201507'),
605608
date('2015-W30-2'),
606609
date('2015202'),
607-
date('2015')
610+
date('2015'),
611+
date('11/18/1986', "MM/dd/yyyy")
608612
] AS theDate
609613
RETURN theDate
610614
----
@@ -620,7 +624,8 @@ RETURN theDate
620624
| 2015-07-21
621625
| 2015-07-21
622626
| 2015-01-01
623-
1+d|Rows: 6
627+
| 1986-11-18
628+
1+d|Rows: 7
624629
625630
|===
626631
@@ -841,10 +846,11 @@ RETURN
841846

842847
.Details
843848
|===
844-
| *Syntax* 3+| `datetime([ input ])`
849+
| *Syntax* 3+| `datetime([ input, pattern ])`
845850
| *Description* 3+| Creates a `ZONED DATETIME` instant.
846-
.2+| *Arguments* | *Name* | *Type* | *Description*
851+
.3+| *Arguments* | *Name* | *Type* | *Description*
847852
| `input` | `ANY` | Either a string representation of a temporal value, a map containing the single key 'timezone', or a map containing temporal values ('year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond', 'timezone') as components.
853+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
848854
| *Returns* 3+| `ZONED DATETIME`
849855
|===
850856

@@ -914,6 +920,7 @@ RETURN
914920
| Selecting a `ZONED DATETIME` or `ZONED TIME` as the `time` component and overwriting the timezone will adjust the local time to keep the same point in time.
915921
| `epochSeconds`/`epochMillis` may be used in conjunction with `nanosecond`.
916922
| `datetime(null)` returns null.
923+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-instance-types-characters[Allowed characters for instance types].
917924

918925
|===
919926

@@ -1118,7 +1125,8 @@ datetime('20150721T21:40-01:30'),
11181125
datetime('2015-W30T2140-02'),
11191126
datetime('2015202T21+18:00'),
11201127
datetime('2015-07-21T21:40:32.142[Europe/London]'),
1121-
datetime('2015-07-21T21:40:32.142-04[America/New_York]')
1128+
datetime('2015-07-21T21:40:32.142-04[America/New_York]'),
1129+
datetime('Tuesday, November 18, AD 1986', 'EEEE, MMMM d, G uuuu')
11221130
] AS theDate
11231131
RETURN theDate
11241132
----
@@ -1136,7 +1144,8 @@ RETURN theDate
11361144
| 2015-07-21T21:00+18:00
11371145
| 2015-07-21T21:40:32.142+01:00[Europe/London]
11381146
| 2015-07-21T21:40:32.142-04:00[America/New_York]
1139-
1+d|Rows: 8
1147+
| 1986-11-18T00:00Z
1148+
1+d|Rows: 9
11401149
11411150
|===
11421151
@@ -1599,10 +1608,11 @@ RETURN
15991608

16001609
.Details
16011610
|===
1602-
| *Syntax* 3+| `localdatetime([ input ])`
1611+
| *Syntax* 3+| `localdatetime([ input, pattern ])`
16031612
| *Description* 3+| Creates a `LOCAL DATETIME` instant.
1604-
.2+| *Arguments* | *Name* | *Type* | *Description*
1613+
.3+| *Arguments* | *Name* | *Type* | *Description*
16051614
| `input` | `ANY` | Either a string representation of a temporal value, a map containing the single key 'timezone', or a map containing temporal values ('year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond') as components.
1615+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
16061616
| *Returns* 3+| `LOCAL DATETIME`
16071617
|===
16081618

@@ -1661,6 +1671,7 @@ RETURN
16611671
| `localdatetime(null)` returns null.
16621672
| If any of the optional parameters are provided, these will override the corresponding components of `datetime`, `date` and/or `time`.
16631673
| `localdatetime(dd)` may be written instead of `+localdatetime({datetime: dd})+`.
1674+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-instance-types-characters[Allowed characters for instance types].
16641675

16651676
|===
16661677

@@ -1829,7 +1840,8 @@ UNWIND [
18291840
localdatetime('2015-07-21T21:40:32.142'),
18301841
localdatetime('2015-W30-2T214032.142'),
18311842
localdatetime('2015-202T21:40:32'),
1832-
localdatetime('2015202T21')
1843+
localdatetime('2015202T21'),
1844+
localdatetime('Tuesday, November 18, AD 1986', 'EEEE, MMMM d, G uuuu')
18331845
] AS theDate
18341846
RETURN theDate
18351847
----
@@ -1843,7 +1855,8 @@ RETURN theDate
18431855
| 2015-07-21T21:40:32.142
18441856
| 2015-07-21T21:40:32
18451857
| 2015-07-21T21:00
1846-
1+d|Rows: 4
1858+
| 1986-11-18T00:00Z
1859+
1+d|Rows: 5
18471860
18481861
|===
18491862
@@ -2179,10 +2192,11 @@ RETURN
21792192

21802193
.Details
21812194
|===
2182-
| *Syntax* 3+| `localtime([ input ])`
2195+
| *Syntax* 3+| `localtime([ input, pattern ])`
21832196
| *Description* 3+| Creates a `LOCAL TIME` instant.
2184-
.2+| *Arguments* | *Name* | *Type* | *Description*
2197+
.3+| *Arguments* | *Name* | *Type* | *Description*
21852198
| `input` | `ANY` | Either a string representation of a temporal value, a map containing the single key 'timezone', or a map containing temporal values ('hour, 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond' as components.
2199+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
21862200
| *Returns* 3+| `LOCAL TIME`
21872201
|===
21882202

@@ -2227,6 +2241,7 @@ RETURN
22272241
| `localtime(null)` returns null.
22282242
| If any of the optional parameters are provided, these will override the corresponding components of `time`.
22292243
| `localtime(tt)` may be written instead of `localtime({time: tt})`.
2244+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-instance-types-characters[Allowed characters for instance types].
22302245

22312246
|===
22322247

@@ -2320,7 +2335,8 @@ UNWIND [
23202335
localtime('21:40:32.142'),
23212336
localtime('214032.142'),
23222337
localtime('21:40'),
2323-
localtime('21')
2338+
localtime('21'),
2339+
localtime('6:04', 'k:mm')
23242340
] AS theTime
23252341
RETURN theTime
23262342
----
@@ -2334,7 +2350,8 @@ RETURN theTime
23342350
| 21:40:32.142
23352351
| 21:40
23362352
| 21:00
2337-
1+d|Rows: 4
2353+
| 06:04
2354+
1+d|Rows: 5
23382355
23392356
|===
23402357
@@ -2574,10 +2591,11 @@ RETURN
25742591

25752592
.Details
25762593
|===
2577-
| *Syntax* 3+| `time([ input ])`
2594+
| *Syntax* 3+| `time([ input, pattern ])`
25782595
| *Description* 3+| Creates a `ZONED TIME` instant.
2579-
.2+| *Arguments* | *Name* | *Type* | *Description*
2596+
.3+| *Arguments* | *Name* | *Type* | *Description*
25802597
| `input` | `ANY` | Either a string representation of a temporal value, a map containing the single key 'timezone', or a map containing temporal values ('hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond', 'timezone') as components.
2598+
| `pattern` | `STRING` | A pattern used to parse the input. If a pattern is provided, `input` must be `STRING`.
25812599
| *Returns* 3+| `ZONED TIME`
25822600
|===
25832601

@@ -2629,6 +2647,7 @@ RETURN
26292647
| `time(tt)` may be written instead of `+time({time: tt})+`.
26302648
| Selecting a `ZONED TIME` or `ZONED DATETIME` value as the `time` component also selects its timezone. If a `LOCAL TIME` or `LOCAL DATETIME` is selected instead, the default timezone is used. In any case, the timezone can be overridden explicitly.
26312649
| Selecting a `ZONED DATETIME` or `ZONED TIME` as the `time` component and overwriting the timezone will adjust the local time to keep the same point in time.
2650+
| The `pattern` argument is constructed from xref:functions/temporal/format.adoc#query-functions-temporal-format-instance-types-characters[Allowed characters for instance types].
26322651

26332652
|===
26342653

@@ -2733,7 +2752,8 @@ time('214032-0100'),
27332752
time('21:40-01:30'),
27342753
time('2140-00:00'),
27352754
time('2140-02'),
2736-
time('22+18:00')
2755+
time('22+18:00'),
2756+
time('6:04', 'k:mm')
27372757
] AS theTime
27382758
RETURN theTime
27392759
----
@@ -2751,7 +2771,8 @@ RETURN theTime
27512771
| 21:40:00Z
27522772
| 21:40:00-02:00
27532773
| 22:00:00+18:00
2754-
1+d|Rows: 8
2774+
| 06:04:00Z
2775+
1+d|Rows: 9
27552776
27562777
|===
27572778

0 commit comments

Comments
 (0)