Skip to content

Commit efeca11

Browse files
committed
examples for instance types
1 parent 03a8731 commit efeca11

File tree

1 file changed

+209
-5
lines changed

1 file changed

+209
-5
lines changed

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

Lines changed: 209 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ Most characters change yield a different output when they are repeated.
7878

7979
| Some characters cannot be applied to certain types, for instance, `u` cannot be used to construct a string for a `LOCAL TIME` because it represents a year which is not part of the temporal value.
8080

81-
| The "text" style is determined by how often the pattern character is repeated: less than 4 characters result in the short form ("AD"). Exactly 4 characters result in the full form ("Anno Domini"). Exactly 5 characters result in the narrow form ("A").
81+
| The "text" presentation is determined by how often the pattern character is repeated: less than 4 characters result in the short form ("AD"). Exactly 4 characters result in the full form ("Anno Domini"). Exactly 5 characters result in the narrow form ("A").
8282

83-
The characters 'L', 'q', and 'c' represent the standalone form of the text styles.
83+
The characters 'L', 'q', and 'c' represent the standalone form of the text presentation.
8484

8585
| A single "number" character outputs the minimum number of digits without padding. With more "number" characters, the number of digits is used as the width of the output field, with the value zero-padded as necessary.
8686

@@ -152,13 +152,13 @@ More characters will result in an error.
152152

153153
|===
154154

155-
.awesome example
155+
.Formatting with year, month, day, hour, minute, second, fraction-of-second and zone-offset
156156
======
157157
158158
.Query
159159
[source, cypher, indent=0]
160160
----
161-
WITH datetime('2024-06-27T14:30:45.123456789+02:00[Europe/Paris]') AS dt
161+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
162162
RETURN format(dt, "yyyy-MM-dd'T'HH:mm:ss.SSSZ") AS x
163163
----
164164
@@ -167,13 +167,217 @@ RETURN format(dt, "yyyy-MM-dd'T'HH:mm:ss.SSSZ") AS x
167167
|===
168168
169169
| x
170-
| "2024-06-27T14:30:45.123+0200"
170+
| "1986-11-18T06:04:45.123+0100"
171+
1+d|Rows: 1
172+
173+
|===
174+
175+
======
176+
177+
.Formatting with day-of-week, month-of-year, day-of-month, era and year
178+
======
179+
180+
.Query
181+
[source, cypher, indent=0]
182+
----
183+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
184+
RETURN format(dt, "EEEE, MMMM d, G uuuu") AS x
185+
----
186+
187+
.Result
188+
[role="queryresult",options="header,footer",cols="1*<m"]
189+
|===
190+
191+
| x
192+
| "Tuesday, November 18, AD 1986"
193+
1+d|Rows: 1
194+
195+
|===
196+
197+
Four occurrences of `E` and `M` (text presentations) output the full form of the day and month.
198+
199+
======
200+
201+
.Formatting with day-of-year and localized day-of-week
202+
======
203+
204+
.Query
205+
[source, cypher, indent=0]
206+
----
207+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
208+
RETURN format(dt, "DDD'th day of the year,' c'rd day of the week'") AS x
209+
----
210+
211+
.Result
212+
[role="queryresult",options="header,footer",cols="1*<m"]
213+
|===
214+
215+
| x
216+
| "322th day of the year, 3rd day of the week"
217+
1+d|Rows: 1
218+
219+
|===
220+
221+
======
222+
223+
.Formatting with day-of-year and localized day-of-week
224+
======
225+
226+
.Query
227+
[source, cypher, indent=0]
228+
----
229+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
230+
RETURN format(dt, "DDD'th day of the year,' c'rd day of the week'") AS x
231+
----
232+
233+
.Result
234+
[role="queryresult",options="header,footer",cols="1*<m"]
235+
|===
236+
237+
| x
238+
| "322th day of the year, 3rd day of the week"
239+
1+d|Rows: 1
240+
241+
|===
242+
243+
======
244+
245+
.Formatting with clock-hour-of-day (1-24), minute-of-hour and time-zone name
246+
======
247+
248+
.Query
249+
[source, cypher, indent=0]
250+
----
251+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
252+
RETURN format(dt, "k:mm z") AS x
253+
----
254+
255+
.Result
256+
[role="queryresult",options="header,footer",cols="1*<m"]
257+
|===
258+
259+
| x
260+
| "6:04 CET"
261+
1+d|Rows: 1
262+
263+
|===
264+
265+
======
266+
267+
.Formatting with hour-of-am-pm (0-11), minute-of-hour and localized zone-offset
268+
======
269+
270+
.Query
271+
[source, cypher, indent=0]
272+
----
273+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
274+
RETURN format(dt, "K:mm O") AS x
275+
----
276+
277+
.Result
278+
[role="queryresult",options="header,footer",cols="1*<m"]
279+
|===
280+
281+
| x
282+
| "6:04 GMT+1"
283+
1+d|Rows: 1
284+
285+
|===
286+
287+
======
288+
289+
.Formatting with month-of-year, day-of-month, milli-of-day, minute-of-hour and second-of-minute
290+
======
291+
292+
.Query
293+
[source, cypher, indent=0]
294+
----
295+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
296+
RETURN format(dt, "LLL d,' minute 'm', second 's', millisecond of the day 'A") AS x
297+
----
298+
299+
.Result
300+
[role="queryresult",options="header,footer",cols="1*<m"]
301+
|===
302+
303+
| x
304+
| "Nov 18, minute 4, second 45, millisecond of the day 21885123"
305+
1+d|Rows: 1
306+
307+
|===
308+
309+
Three occurrences of `L` (number/text presentation) output the short form ("Nov").
310+
311+
======
312+
313+
.Formatting with nano-of-second and nano-of-day
314+
======
315+
316+
.Query
317+
[source, cypher, indent=0]
318+
----
319+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
320+
RETURN format(dt, "'Nano of second: 'n', nano of day: 'N") AS x
321+
----
322+
323+
.Result
324+
[role="queryresult",options="header,footer",cols="1*<m"]
325+
|===
326+
327+
| x
328+
| "Nano of second: 123456789, nano of day: 21885123456789"
329+
1+d|Rows: 1
330+
331+
|===
332+
333+
======
334+
335+
.Formatting with quarter-of-year and year-of-era
336+
======
337+
338+
.Query
339+
[source, cypher, indent=0]
340+
----
341+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
342+
RETURN format(dt, "QQQQ' of 'yyyy") AS x
343+
----
344+
345+
.Result
346+
[role="queryresult",options="header,footer",cols="1*<m"]
347+
|===
348+
349+
| x
350+
| "4th quarter of 1986"
171351
1+d|Rows: 1
172352
173353
|===
174354
175355
======
176356

357+
.
358+
======
359+
360+
.Query
361+
[source, cypher, indent=0]
362+
----
363+
WITH datetime('1986-11-18T6:04:45.123456789+01:00[Europe/Berlin]') AS dt
364+
RETURN format(dt, "pppYY") AS x
365+
----
366+
367+
.Result
368+
[role="queryresult",options="header,footer",cols="1*<m"]
369+
|===
370+
371+
| x
372+
| " 86"
373+
1+d|Rows: 1
374+
375+
|===
376+
377+
The three occurrences of `p` add one space character of padding to the two digit form output by two occurrences of `Y`.
378+
379+
======
380+
177381
[[query-functions-temporal-format-duration-types]]
178382
=== Duration types
179383

0 commit comments

Comments
 (0)