Temporal functions - instant types
Temporal functions allow for the creation and manipulation of values for each temporal type — DATE
, ZONED TIME
, LOCAL TIME
, ZONED DATETIME
, and LOCAL DATETIME
.
See also Temporal (Date/Time) values and Temporal operators. |
Temporal instant types
An overview of temporal instant type creation
Each function bears the same name as the type, and construct the type they correspond to in one of four ways:
-
Capturing the current time.
-
Composing the components of the type.
-
Parsing a string representation of the temporal value.
-
Selecting and composing components from another temporal value by
-
either combining temporal values (such as combining a
DATE
with aZONED TIME
to create aZONED DATETIME
), or -
selecting parts from a temporal value (such as selecting the
DATE
from aZONED DATETIME
); the extractors — groups of components which can be selected — are:-
date
— contains all components for aDATE
(conceptually year, month and day). -
time
— contains all components for aZONED TIME
(hour, minute, second, and sub-seconds; namely millisecond, microsecond and nanosecond). If the type being created and the type from which the time component is being selected both containtimezone
(and atimezone
is not explicitly specified) thetimezone
is also selected. -
datetime
— selects all components, and is useful for overriding specific components. Analogously totime
, if the type being created and the type from which the time component is being selected both containtimezone
(and atimezone
is not explicitly specified) thetimezone
is also selected.
-
-
In effect, this allows for the conversion between different temporal types, and allowing for 'missing' components to be specified.
-
Function | Date | Time | LocalTime | DateTime | LocalDateTime |
---|---|---|---|---|---|
Getting the current value. |
|||||
Creating a calendar-based (Year-Month-Day) value. |
|||||
Creating a week-based (Year-Week-Day) value. |
|||||
Creating a quarter-based (Year-Quarter-Day) value. |
|||||
Creating an ordinal (Year-Day) value. |
|||||
Creating a value from time components. |
|||||
Creating a value from other temporal values using extractors (i.e. converting between different types). |
|||||
Creating a value from a string. |
|||||
Creating a value from a timestamp. |
All the temporal instant types — including those that do not contain time zone information support such as |
Controlling which clock to use
The functions which create temporal instant values based on the current instant use the statement
clock as default.
However, there are three different clocks available for more fine-grained control:
-
transaction
: The same instant is produced for each invocation within the same transaction. A different time may be produced for different transactions. -
statement
: The same instant is produced for each invocation within the same statement. A different time may be produced for different statements within the same transaction. -
realtime
: The instant produced will be the live clock of the system.
The following table lists the different sub-functions for specifying the clock to be used when creating the current temporal instant value:
Type | default | transaction | statement | realtime |
---|---|---|---|---|
Date |
||||
Time |
||||
LocalTime |
||||
DateTime |
||||
LocalDateTime |
Truncating temporal values
A temporal instant value can be created by truncating another temporal instant value at the nearest preceding point in time at a specified component boundary (namely, a truncation unit). A temporal instant value created in this way will have all components which are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit. This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
The following truncation units are supported:
-
millennium
: Select the temporal instant corresponding to the millenium of the given instant. -
century
: Select the temporal instant corresponding to the century of the given instant. -
decade
: Select the temporal instant corresponding to the decade of the given instant. -
year
: Select the temporal instant corresponding to the year of the given instant. -
weekYear
: Select the temporal instant corresponding to the first day of the first week of the week-year of the given instant. -
quarter
: Select the temporal instant corresponding to the quarter of the year of the given instant. -
month
: Select the temporal instant corresponding to the month of the given instant. -
week
: Select the temporal instant corresponding to the week of the given instant. -
day
: Select the temporal instant corresponding to the month of the given instant. -
hour
: Select the temporal instant corresponding to the hour of the given instant. -
minute
: Select the temporal instant corresponding to the minute of the given instant. -
second
: Select the temporal instant corresponding to the second of the given instant. -
millisecond
: Select the temporal instant corresponding to the millisecond of the given instant. -
microsecond
: Select the temporal instant corresponding to the microsecond of the given instant.
The following table lists the supported truncation units and the corresponding sub-functions:
Truncation unit | Date | Time | LocalTime | DateTime | LocalDateTime |
---|---|---|---|---|---|
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
date()
Details for using the date()
function.
Getting the current DATE
date()
returns the current DATE
value.
If no time zone parameter is specified, the local time zone will be used.
Syntax:
date([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A string expression that represents the time zone. |
Considerations:
If no parameters are provided, |
RETURN date() AS currentDate
The current date is returned.
currentDate |
---|
|
Rows: 1 |
RETURN date({timezone: 'America/Los Angeles'}) AS currentDateInLA
The current date in California is returned.
currentDateInLA |
---|
|
Rows: 1 |
date.transaction()
date.transaction()
returns the current DATE
value using the transaction
clock.
This value will be the same for each invocation within the same transaction.
However, a different value may be produced for different transactions.
Syntax:
date.transaction([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN date.transaction() AS currentDate
currentDate |
---|
|
Rows: 1 |
date.statement()
date.statement()
returns the current DATE
value using the statement
clock.
This value will be the same for each invocation within the same statement.
However, a different value may be produced for different statements within the same transaction.
Syntax:
date.statement([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN date.statement() AS currentDate
currentDate |
---|
|
Rows: 1 |
date.realtime()
date.realtime()
returns the current DATE
value using the realtime
clock.
This value will be the live clock of the system.
Syntax:
date.realtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN date.realtime() AS currentDate
currentDate |
---|
|
Rows: 1 |
RETURN date.realtime('America/Los Angeles') AS currentDateInLA
currentDateInLA |
---|
|
Rows: 1 |
Creating a calendar (Year-Month-Day) DATE
date()
returns a DATE
value with the specified year, month and day component values.
Syntax:
date({year [, month, day]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
Considerations:
The day of the month component will default to |
The month component will default to |
If |
UNWIND [
date({year: 1984, month: 10, day: 11}),
date({year: 1984, month: 10}),
date({year: 1984})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
Rows: 3 |
Creating a week (Year-Week-Day) DATE
date()
returns a DATE
value with the specified year, week and dayOfWeek component values.
Syntax:
date({year [, week, dayOfWeek]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
Considerations:
The day of the week component will default to |
The week component will default to |
If |
UNWIND [
date({year: 1984, week: 10, dayOfWeek: 3}),
date({year: 1984, week: 10}),
date({year: 1984})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
Rows: 3 |
Creating a quarter (Year-Quarter-Day) DATE
date()
returns a DATE
value with the specified year, quarter and dayOfQuarter component values.
Syntax:
date({year [, quarter, dayOfQuarter]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
Considerations:
The day of the quarter component will default to |
The quarter component will default to |
If |
UNWIND [
date({year: 1984, quarter: 3, dayOfQuarter: 45}),
date({year: 1984, quarter: 3}),
date({year: 1984})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
Rows: 3 |
Creating an ordinal (Year-Day) DATE
date()
returns a DATE
value with the specified year and ordinalDay component values.
Syntax:
date({year [, ordinalDay]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
Considerations:
The ordinal day of the year component will default to |
UNWIND [
date({year: 1984, ordinalDay: 202}),
date({year: 1984})
] AS theDate
RETURN theDate
The date corresponding to 11 February 1984
is returned.
theDate |
---|
|
|
Rows: 2 |
Creating a DATE
from a STRING
date()
returns the DATE
value obtained by parsing a STRING
representation of a temporal value.
Syntax:
date(temporalValue)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string representing a temporal value. |
Considerations:
|
|
|
UNWIND [
date('2015-07-21'),
date('2015-07'),
date('201507'),
date('2015-W30-2'),
date('2015202'),
date('2015')
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
|
|
Rows: 6 |
Creating a DATE
using other temporal values as components
date()
returns the DATE
value obtained by selecting and composing components from another temporal value.
In essence, this allows a ZONED DATETIME
or LOCAL DATETIME
value to be converted to a DATE
, and for "missing" components to be provided.
Syntax:
date({date [, year, month, day, week, dayOfWeek, quarter, dayOfQuarter, ordinalDay]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A |
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
If any of the optional parameters are provided, these will override the corresponding components of |
|
UNWIND [
date({year: 1984, month: 11, day: 11}),
localdatetime({year: 1984, month: 11, day: 11, hour: 12, minute: 31, second: 14}),
datetime({year: 1984, month: 11, day: 11, hour: 12, timezone: '+01:00'})
] AS dd
RETURN date({date: dd}) AS dateOnly, date({date: dd, day: 28}) AS dateDay
dateOnly | dateDay |
---|---|
|
|
|
|
|
|
Rows: 3 |
Truncating a DATE
date.truncate()
returns the DATE
value obtained by truncating a specified temporal instant value at the nearest preceding point in time at the specified component boundary (which is denoted by the truncation unit passed as a parameter to the function).
In other words, the DATE
returned will have all components that are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit.
This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
For example, day
— with some value x
— may be provided when the truncation unit string is 'year'
in order to ensure the returned value has the day set to x
instead of the default day (which is 1
).
Syntax:
date.truncate(unit [, temporalInstantValue [, mapOfComponents ] ])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression evaluating to one of the following strings: |
|
An expression of one of the following types: |
|
An expression evaluating to a map containing components less significant than |
Considerations:
Any component that is provided in |
Any component that is not contained in |
If |
If |
WITH
datetime({
year: 2017, month: 11, day: 11,
hour: 12, minute: 31, second: 14, nanosecond: 645876123,
timezone: '+01:00'
}) AS d
RETURN
date.truncate('millennium', d) AS truncMillenium,
date.truncate('century', d) AS truncCentury,
date.truncate('decade', d) AS truncDecade,
date.truncate('year', d, {day: 5}) AS truncYear,
date.truncate('weekYear', d) AS truncWeekYear,
date.truncate('quarter', d) AS truncQuarter,
date.truncate('month', d) AS truncMonth,
date.truncate('week', d, {dayOfWeek: 2}) AS truncWeek,
date.truncate('day', d) AS truncDay
truncMillenium | truncCentury | truncDecade | truncYear | truncWeekYear | truncQuarter | truncMonth | truncWeek | truncDay |
---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
Rows: 1 |
datetime()
Details for using the datetime()
function.
Getting the current ZONED DATETIME
datetime()
returns the current ZONED DATETIME
value.
If no time zone parameter is specified, the default time zone will be used.
Syntax:
datetime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A string expression that represents the time zone. |
Considerations:
If no parameters are provided, |
RETURN datetime() AS currentDateTime
The current date and time using the local time zone is returned.
currentDateTime |
---|
|
Rows: 1 |
RETURN datetime({timezone: 'America/Los Angeles'}) AS currentDateTimeInLA
The current date and time of day in California is returned.
currentDateTimeInLA |
---|
|
Rows: 1 |
datetime.transaction()
datetime.transaction()
returns the current ZONED DATETIME
value using the transaction
clock.
This value will be the same for each invocation within the same transaction.
However, a different value may be produced for different transactions.
Syntax:
datetime.transaction([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN datetime.transaction() AS currentDateTime
currentDateTime |
---|
|
Rows: 1 |
RETURN datetime.transaction('America/Los Angeles') AS currentDateTimeInLA
currentDateTimeInLA |
---|
|
Rows: 1 |
datetime.statement()
datetime.statement()
returns the current ZONED DATETIME
value using the statement
clock.
This value will be the same for each invocation within the same statement.
However, a different value may be produced for different statements within the same transaction.
Syntax:
datetime.statement([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN datetime.statement() AS currentDateTime
currentDateTime |
---|
|
Rows: 1 |
datetime.realtime()
datetime.realtime()
returns the current ZONED DATETIME
value using the realtime
clock.
This value will be the live clock of the system.
Syntax:
datetime.realtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN datetime.realtime() AS currentDateTime
currentDateTime |
---|
|
Rows: 1 |
Creating a calendar (Year-Month-Day) ZONED DATETIME
datetime()
returns a ZONED DATETIME
value with the specified year, month, day, hour, minute, second, millisecond, microsecond, nanosecond and timezone component values.
Syntax:
datetime({year [, month, day, hour, minute, second, millisecond, microsecond, nanosecond, timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
The month component will default to |
The day of the month component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
The timezone component will default to the configured default time zone if |
If |
The least significant components in the set |
One or more of |
UNWIND [
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, second: 14, millisecond: 123, microsecond: 456, nanosecond: 789}),
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, second: 14, millisecond: 645, timezone: '+01:00'}),
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, second: 14, nanosecond: 645876123, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, second: 14, timezone: '+01:00'}),
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, second: 14}),
datetime({year: 1984, month: 10, day: 11, hour: 12, minute: 31, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, month: 10, day: 11, hour: 12, timezone: '+01:00'}),
datetime({year: 1984, month: 10, day: 11, timezone: 'Europe/Stockholm'})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
|
|
|
|
Rows: 8 |
Creating a week (Year-Week-Day) ZONED DATETIME
datetime()
returns a ZONED DATETIME
value with the specified year, week, dayOfWeek, hour, minute, second, millisecond, microsecond, nanosecond and timezone component values.
Syntax:
datetime({year [, week, dayOfWeek, hour, minute, second, millisecond, microsecond, nanosecond, timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
The week component will default to |
The day of the week component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
The timezone component will default to the configured default time zone if |
If |
The least significant components in the set |
One or more of |
UNWIND [
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, minute: 31, second: 14, millisecond: 645}),
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}),
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, minute: 31, second: 14, nanosecond: 645876123, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, minute: 31, second: 14, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, minute: 31, second: 14}),
datetime({year: 1984, week: 10, dayOfWeek: 3, hour: 12, timezone: '+01:00'}),
datetime({year: 1984, week: 10, dayOfWeek: 3, timezone: 'Europe/Stockholm'})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
|
|
|
Rows: 7 |
Creating a quarter (Year-Quarter-Day) ZONED DATETIME
datetime()
returns a ZONED DATETIME
value with the specified year, quarter, dayOfQuarter, hour, minute, second, millisecond, microsecond, nanosecond and timezone component values.
Syntax:
datetime({year [, quarter, dayOfQuarter, hour, minute, second, millisecond, microsecond, nanosecond, timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
The quarter component will default to |
The day of the quarter component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
The timezone component will default to the configured default time zone if |
If |
The least significant components in the set |
One or more of |
UNWIND [
datetime({year: 1984, quarter: 3, dayOfQuarter: 45, hour: 12, minute: 31, second: 14, microsecond: 645876}),
datetime({year: 1984, quarter: 3, dayOfQuarter: 45, hour: 12, minute: 31, second: 14, timezone: '+01:00'}),
datetime({year: 1984, quarter: 3, dayOfQuarter: 45, hour: 12, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, quarter: 3, dayOfQuarter: 45})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
Rows: 4 |
Creating an ordinal (Year-Day) ZONED DATETIME
datetime()
returns a ZONED DATETIME
value with the specified year, ordinalDay, hour, minute, second, millisecond, microsecond, nanosecond and timezone component values.
Syntax:
datetime({year [, ordinalDay, hour, minute, second, millisecond, microsecond, nanosecond, timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
The ordinal day of the year component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
The timezone component will default to the configured default time zone if |
If |
The least significant components in the set |
One or more of |
UNWIND [
datetime({year: 1984, ordinalDay: 202, hour: 12, minute: 31, second: 14, millisecond: 645}),
datetime({year: 1984, ordinalDay: 202, hour: 12, minute: 31, second: 14, timezone: '+01:00'}),
datetime({year: 1984, ordinalDay: 202, timezone: 'Europe/Stockholm'}),
datetime({year: 1984, ordinalDay: 202})
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
Rows: 4 |
Creating a ZONED DATETIME
from a STRING
datetime()
returns the ZONED DATETIME
value obtained by parsing a STRING
representation of a temporal value.
Syntax:
datetime(temporalValue)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string representing a temporal value. |
Considerations:
|
The timezone component will default to the configured default time zone if it is omitted. |
|
|
UNWIND [
datetime('2015-07-21T21:40:32.142+0100'),
datetime('2015-W30-2T214032.142Z'),
datetime('2015T214032-0100'),
datetime('20150721T21:40-01:30'),
datetime('2015-W30T2140-02'),
datetime('2015202T21+18:00'),
datetime('2015-07-21T21:40:32.142[Europe/London]'),
datetime('2015-07-21T21:40:32.142-04[America/New_York]')
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
|
|
|
|
Rows: 8 |
Creating a ZONED DATETIME
using other temporal values as components
datetime()
returns the ZONED DATETIME
value obtained by selecting and composing components from another temporal value.
In essence, this allows a DATE
, LOCAL DATETIME
, ZONED TIME
or LOCAL TIME
value to be converted to a ZONED DATETIME
, and for "missing" components to be provided.
Syntax:
datetime({datetime [, year, ..., timezone]}) | datetime({date [, year, ..., timezone]}) | datetime({time [, year, ..., timezone]}) | datetime({date, time [, year, ..., timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A |
|
A |
|
A |
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
If any of the optional parameters are provided, these will override the corresponding components of |
|
Selecting a |
Selecting a |
Selecting a |
The following query shows the various usages of datetime({date [, year, ..., timezone]})
.
WITH date({year: 1984, month: 10, day: 11}) AS dd
RETURN
datetime({date: dd, hour: 10, minute: 10, second: 10}) AS dateHHMMSS,
datetime({date: dd, hour: 10, minute: 10, second: 10, timezone:'+05:00'}) AS dateHHMMSSTimezone,
datetime({date: dd, day: 28, hour: 10, minute: 10, second: 10}) AS dateDDHHMMSS,
datetime({date: dd, day: 28, hour: 10, minute: 10, second: 10, timezone:'Pacific/Honolulu'}) AS dateDDHHMMSSTimezone
dateHHMMSS | dateHHMMSSTimezone | dateDDHHMMSS | dateDDHHMMSSTimezone |
---|---|---|---|
|
|
|
|
Rows: 1 |
The following query shows the various usages of datetime({time [, year, …, timezone]})
.
WITH time({hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}) AS tt
RETURN
datetime({year: 1984, month: 10, day: 11, time: tt}) AS YYYYMMDDTime,
datetime({year: 1984, month: 10, day: 11, time: tt, timezone:'+05:00'}) AS YYYYMMDDTimeTimezone,
datetime({year: 1984, month: 10, day: 11, time: tt, second: 42}) AS YYYYMMDDTimeSS,
datetime({year: 1984, month: 10, day: 11, time: tt, second: 42, timezone: 'Pacific/Honolulu'}) AS YYYYMMDDTimeSSTimezone
YYYYMMDDTime | YYYYMMDDTimeTimezone | YYYYMMDDTimeSS | YYYYMMDDTimeSSTimezone |
---|---|---|---|
|
|
|
|
Rows: 1 |
The following query shows the various usages of datetime({date, time [, year, ..., timezone]})
; i.e. combining a DATE
and a ZONED TIME
value to create a single ZONED DATETIME
value.
WITH
date({year: 1984, month: 10, day: 11}) AS dd,
localtime({hour: 12, minute: 31, second: 14, millisecond: 645}) AS tt
RETURN
datetime({date: dd, time: tt}) AS dateTime,
datetime({date: dd, time: tt, timezone: '+05:00'}) AS dateTimeTimezone,
datetime({date: dd, time: tt, day: 28, second: 42}) AS dateTimeDDSS,
datetime({date: dd, time: tt, day: 28, second: 42, timezone: 'Pacific/Honolulu'}) AS dateTimeDDSSTimezone
dateTime | dateTimeTimezone | dateTimeDDSS | dateTimeDDSSTimezone |
---|---|---|---|
|
|
|
|
Rows: 1 |
The following query shows the various usages of datetime({datetime [, year, ..., timezone]})
.
WITH
datetime({
year: 1984, month: 10, day: 11,
hour: 12,
timezone: 'Europe/Stockholm'
}) AS dd
RETURN
datetime({datetime: dd}) AS dateTime,
datetime({datetime: dd, timezone: '+05:00'}) AS dateTimeTimezone,
datetime({datetime: dd, day: 28, second: 42}) AS dateTimeDDSS,
datetime({datetime: dd, day: 28, second: 42, timezone: 'Pacific/Honolulu'}) AS dateTimeDDSSTimezone
dateTime | dateTimeTimezone | dateTimeDDSS | dateTimeDDSSTimezone |
---|---|---|---|
|
|
|
|
Rows: 1 |
Creating a ZONED DATETIME
from a timestamp
datetime()
returns the ZONED DATETIME
value at the specified number of seconds or milliseconds from the UNIX epoch in the UTC time zone.
Conversions to other temporal instant types from UNIX epoch representations can be achieved by transforming a ZONED DATETIME
value to one of these types.
Syntax:
datetime({ epochSeconds | epochMillis })
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A numeric value representing the number of seconds from the UNIX epoch in the UTC time zone. |
|
A numeric value representing the number of milliseconds from the UNIX epoch in the UTC time zone. |
Considerations:
|
RETURN datetime({epochSeconds: timestamp() / 1000, nanosecond: 23}) AS theDate
theDate |
---|
|
Rows: 1 |
RETURN datetime({epochMillis: 424797300000}) AS theDate
theDate |
---|
|
Rows: 1 |
Truncating a ZONED DATETIME
datetime.truncate()
returns the ZONED DATETIME
value obtained by truncating a specified temporal instant value at the nearest preceding point in time at the specified component boundary (which is denoted by the truncation unit passed as a parameter to the function).
In other words, the ZONED DATETIME
returned will have all components that are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit.
This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
For example, day
— with some value x
— may be provided when the truncation unit string is 'year'
in order to ensure the returned value has the day set to x
instead of the default day (which is 1
).
Syntax:
datetime.truncate(unit [, temporalInstantValue [, mapOfComponents ] ])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression evaluating to one of the following strings: |
|
An expression of one of the following types: |
|
An expression evaluating to a map containing components less significant than |
Considerations:
|
The time zone of |
If |
If |
Any component that is provided in |
Any component that is not contained in |
If |
If |
WITH
datetime({
year:2017, month:11, day:11,
hour:12, minute:31, second:14, nanosecond: 645876123,
timezone: '+03:00'
}) AS d
RETURN
datetime.truncate('millennium', d, {timezone: 'Europe/Stockholm'}) AS truncMillenium,
datetime.truncate('year', d, {day: 5}) AS truncYear,
datetime.truncate('month', d) AS truncMonth,
datetime.truncate('day', d, {millisecond: 2}) AS truncDay,
datetime.truncate('hour', d) AS truncHour,
datetime.truncate('second', d) AS truncSecond
truncMillenium | truncYear | truncMonth | truncDay | truncHour | truncSecond |
---|---|---|---|---|---|
|
|
|
|
|
|
Rows: 1 |
localdatetime()
Details for using the localdatetime()
function.
Getting the current LOCAL DATETIME
localdatetime()
returns the current LOCAL DATETIME
value.
If no time zone parameter is specified, the local time zone will be used.
Syntax:
localdatetime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A string expression that represents the time zone. |
Considerations:
If no parameters are provided, |
RETURN localdatetime() AS now
The current local date and time (i.e. in the local time zone) is returned.
now |
---|
|
Rows: 1 |
RETURN localdatetime({timezone: 'America/Los Angeles'}) AS now
The current local date and time in California is returned.
now |
---|
|
Rows: 1 |
localdatetime.transaction()
localdatetime.transaction()
returns the current LOCAL DATETIME
value using the transaction
clock.
This value will be the same for each invocation within the same transaction.
However, a different value may be produced for different transactions.
Syntax:
localdatetime.transaction([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localdatetime.transaction() AS now
now |
---|
|
Rows: 1 |
localdatetime.statement()
localdatetime.statement()
returns the current LOCAL DATETIME
value using the statement
clock.
This value will be the same for each invocation within the same statement.
However, a different value may be produced for different statements within the same transaction.
Syntax:
localdatetime.statement([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localdatetime.statement() AS now
now |
---|
|
Rows: 1 |
localdatetime.realtime()
localdatetime.realtime()
returns the current LOCAL DATETIME
value using the realtime
clock.
This value will be the live clock of the system.
Syntax:
localdatetime.realtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localdatetime.realtime() AS now
now |
---|
|
Rows: 1 |
RETURN localdatetime.realtime('America/Los Angeles') AS nowInLA
nowInLA |
---|
|
Rows: 1 |
Creating a calendar (Year-Month-Day) LOCAL DATETIME
localdatetime()
returns a LOCAL DATETIME
value with the specified year, month, day, hour, minute, second, millisecond, microsecond and nanosecond component values.
Syntax:
localdatetime({year [, month, day, hour, minute, second, millisecond, microsecond, nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
The month component will default to |
The day of the month component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
If |
The least significant components in the set |
One or more of |
RETURN
localdatetime({
year: 1984, month: 10, day: 11,
hour: 12, minute: 31, second: 14, millisecond: 123, microsecond: 456, nanosecond: 789
}) AS theDate
theDate |
---|
|
Rows: 1 |
Creating a week (Year-Week-Day) LOCAL DATETIME
localdatetime()
returns a LOCAL DATETIME
value with the specified year, week, dayOfWeek, hour, minute, second, millisecond, microsecond and nanosecond component values.
Syntax:
localdatetime({year [, week, dayOfWeek, hour, minute, second, millisecond, microsecond, nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
The week component will default to |
The day of the week component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
If |
The least significant components in the set |
One or more of |
RETURN
localdatetime({
year: 1984, week: 10, dayOfWeek: 3,
hour: 12, minute: 31, second: 14, millisecond: 645
}) AS theDate
theDate |
---|
|
Rows: 1 |
Creating a quarter (Year-Quarter-Day) ZONED DATETIME
localdatetime()
returns a LOCAL DATETIME
value with the specified year, quarter, dayOfQuarter, hour, minute, second, millisecond, microsecond and nanosecond component values.
Syntax:
localdatetime({year [, quarter, dayOfQuarter, hour, minute, second, millisecond, microsecond, nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
The quarter component will default to |
The day of the quarter component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
If |
The least significant components in the set |
One or more of |
RETURN
localdatetime({
year: 1984, quarter: 3, dayOfQuarter: 45,
hour: 12, minute: 31, second: 14, nanosecond: 645876123
}) AS theDate
theDate |
---|
|
Rows: 1 |
Creating an ordinal (Year-Day) LOCAL DATETIME
localdatetime()
returns a LOCAL DATETIME
value with the specified year, ordinalDay, hour, minute, second, millisecond, microsecond and nanosecond component values.
Syntax:
localdatetime({year [, ordinalDay, hour, minute, second, millisecond, microsecond, nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
The ordinal day of the year component will default to |
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
If |
The least significant components in the set |
One or more of |
RETURN
localdatetime({
year: 1984, ordinalDay: 202,
hour: 12, minute: 31, second: 14, microsecond: 645876
}) AS theDate
theDate |
---|
|
Rows: 1 |
Creating a LOCAL DATETIME
from a STRING
localdatetime()
returns the LOCAL DATETIME
value obtained by parsing a STRING
representation of a temporal value.
Syntax:
localdatetime(temporalValue)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string representing a temporal value. |
Considerations:
|
|
|
UNWIND [
localdatetime('2015-07-21T21:40:32.142'),
localdatetime('2015-W30-2T214032.142'),
localdatetime('2015-202T21:40:32'),
localdatetime('2015202T21')
] AS theDate
RETURN theDate
theDate |
---|
|
|
|
|
Rows: 4 |
Creating a LOCAL DATETIME
using other temporal values as components
localdatetime()
returns the LOCAL DATETIME
value obtained by selecting and composing components from another temporal value.
In essence, this allows a DATE
, ZONED DATETIME
, ZONED TIME
or LOCAL TIME
value to be converted to a LOCAL DATETIME
, and for "missing" components to be provided.
Syntax:
localdatetime({datetime [, year, ..., nanosecond]}) | localdatetime({date [, year, ..., nanosecond]}) | localdatetime({time [, year, ..., nanosecond]}) | localdatetime({date, time [, year, ..., nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A |
|
A |
|
A |
|
An expression consisting of at least four digits that specifies the year. |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
If any of the optional parameters are provided, these will override the corresponding components of |
|
The following query shows the various usages of localdatetime({date [, year, ..., nanosecond]})
.
WITH date({year: 1984, month: 10, day: 11}) AS dd
RETURN
localdatetime({date: dd, hour: 10, minute: 10, second: 10}) AS dateHHMMSS,
localdatetime({date: dd, day: 28, hour: 10, minute: 10, second: 10}) AS dateDDHHMMSS
dateHHMMSS | dateDDHHMMSS |
---|---|
|
|
Rows: 1 |
The following query shows the various usages of localdatetime({time [, year, ..., nanosecond]})
.
WITH time({hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}) AS tt
RETURN
localdatetime({year: 1984, month: 10, day: 11, time: tt}) AS YYYYMMDDTime,
localdatetime({year: 1984, month: 10, day: 11, time: tt, second: 42}) AS YYYYMMDDTimeSS
YYYYMMDDTime | YYYYMMDDTimeSS |
---|---|
|
|
Rows: 1 |
The following query shows the various usages of localdatetime({date, time [, year, ..., nanosecond]})
; i.e. combining a DATE
and a ZONED TIME
value to create a single LOCAL DATETIME
value.
WITH
date({year: 1984, month: 10, day: 11}) AS dd,
time({hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}) AS tt
RETURN
localdatetime({date: dd, time: tt}) AS dateTime,
localdatetime({date: dd, time: tt, day: 28, second: 42}) AS dateTimeDDSS
dateTime | dateTimeDDSS |
---|---|
|
|
Rows: 1 |
The following query shows the various usages of localdatetime({datetime [, year, ..., nanosecond]})
.
WITH
datetime({
year: 1984, month: 10, day: 11,
hour: 12,
timezone: '+01:00'
}) AS dd
RETURN
localdatetime({datetime: dd}) AS dateTime,
localdatetime({datetime: dd, day: 28, second: 42}) AS dateTimeDDSS
dateTime | dateTimeDDSS |
---|---|
|
|
Rows: 1 |
Truncating a LOCAL DATETIME
localdatetime.truncate()
returns the LOCAL DATETIME
value obtained by truncating a specified temporal instant value at the nearest preceding point in time at the specified component boundary (which is denoted by the truncation unit passed as a parameter to the function).
In other words, the LOCAL DATETIME
returned will have all components that are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit.
This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
For example, day
— with some value x
— may be provided when the truncation unit string is 'year'
in order to ensure the returned value has the day set to x
instead of the default day (which is 1
).
Syntax:
localdatetime.truncate(unit [, temporalInstantValue [, mapOfComponents ] ])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression evaluating to one of the following strings: |
|
An expression of one of the following types: |
|
An expression evaluating to a map containing components less significant than |
Considerations:
|
Any component that is provided in |
Any component that is not contained in |
If |
If |
WITH
localdatetime({
year: 2017, month: 11, day: 11,
hour: 12, minute: 31, second: 14, nanosecond: 645876123
}) AS d
RETURN
localdatetime.truncate('millennium', d) AS truncMillenium,
localdatetime.truncate('year', d, {day: 2}) AS truncYear,
localdatetime.truncate('month', d) AS truncMonth,
localdatetime.truncate('day', d) AS truncDay,
localdatetime.truncate('hour', d, {nanosecond: 2}) AS truncHour,
localdatetime.truncate('second', d) AS truncSecond
truncMillenium | truncYear | truncMonth | truncDay | truncHour | truncSecond |
---|---|---|---|---|---|
|
|
|
|
|
|
Rows: 1 |
localtime()
Details for using the localtime()
function.
Getting the current LOCAL TIME
localtime()
returns the current LOCAL TIME
value.
If no time zone parameter is specified, the local time zone will be used.
Syntax:
localtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A string expression that represents the time zone. |
Considerations:
If no parameters are provided, |
RETURN localtime() AS now
The current local time (i.e. in the local time zone) is returned.
now |
---|
|
Rows: 1 |
RETURN localtime({timezone: 'America/Los Angeles'}) AS nowInLA
The current local time in California is returned.
nowInLA |
---|
|
Rows: 1 |
localtime.transaction()
localtime.transaction()
returns the current LOCAL TIME
value using the transaction
clock.
This value will be the same for each invocation within the same transaction.
However, a different value may be produced for different transactions.
Syntax:
localtime.transaction([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localtime.transaction() AS now
now |
---|
|
Rows: 1 |
localtime.statement()
localtime.statement()
returns the current LOCAL TIME
value using the statement
clock.
This value will be the same for each invocation within the same statement.
However, a different value may be produced for different statements within the same transaction.
Syntax:
localtime.statement([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localtime.statement() AS now
now |
---|
|
Rows: 1 |
RETURN localtime.statement('America/Los Angeles') AS nowInLA
nowInLA |
---|
|
Rows: 1 |
localtime.realtime()
localtime.realtime()
returns the current LOCAL TIME
value using the realtime
clock.
This value will be the live clock of the system.
Syntax:
localtime.realtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN localtime.realtime() AS now
now |
---|
|
Rows: 1 |
Creating a LOCAL TIME
localtime()
returns a LOCAL TIME
value with the specified hour, minute, second, millisecond, microsecond and nanosecond component values.
Syntax:
localtime({hour [, minute, second, millisecond, microsecond, nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
If |
The least significant components in the set |
One or more of |
UNWIND [
localtime({hour: 12, minute: 31, second: 14, nanosecond: 789, millisecond: 123, microsecond: 456}),
localtime({hour: 12, minute: 31, second: 14}),
localtime({hour: 12})
] AS theTime
RETURN theTime
theTime |
---|
|
|
|
Rows: 3 |
Creating a LOCAL TIME
from a STRING
localtime()
returns the LOCAL TIME
value obtained by parsing a STRING
representation of a temporal value.
Syntax:
localtime(temporalValue)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string representing a temporal value. |
Considerations:
|
|
|
UNWIND [
localtime('21:40:32.142'),
localtime('214032.142'),
localtime('21:40'),
localtime('21')
] AS theTime
RETURN theTime
theTime |
---|
|
|
|
|
Rows: 4 |
Creating a LOCAL TIME
using other temporal values as components
localtime()
returns the LOCAL TIME
value obtained by selecting and composing components from another temporal value.
In essence, this allows a ZONED DATETIME
, LOCAL DATETIME
or ZONED TIME
value to be converted to a LOCAL TIME
, and for "missing" components to be provided.
Syntax:
localtime({time [, hour, ..., nanosecond]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
Considerations:
If any of the optional parameters are provided, these will override the corresponding components of |
|
WITH time({hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}) AS tt
RETURN
localtime({time: tt}) AS timeOnly,
localtime({time: tt, second: 42}) AS timeSS
timeOnly | timeSS |
---|---|
|
|
Rows: 1 |
Truncating a LOCAL TIME
localtime.truncate()
returns the LOCAL TIME
value obtained by truncating a specified temporal instant value at the nearest preceding point in time at the specified component boundary (which is denoted by the truncation unit passed as a parameter to the function).
In other words, the LOCAL TIME
returned will have all components that are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit.
This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
For example, minute
— with some value x
— may be provided when the truncation unit string is 'hour'
in order to ensure the returned value has the minute set to x
instead of the default minute (which is 1
).
Syntax:
localtime.truncate(unit [, temporalInstantValue [, mapOfComponents ] ])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression evaluating to one of the following strings: |
|
An expression of one of the following types: |
|
An expression evaluating to a map containing components less significant than |
Considerations:
Truncating time to day — i.e. |
Any component that is provided in |
Any component that is not contained in |
If |
If |
WITH time({hour: 12, minute: 31, second: 14, nanosecond: 645876123, timezone: '-01:00'}) AS t
RETURN
localtime.truncate('day', t) AS truncDay,
localtime.truncate('hour', t) AS truncHour,
localtime.truncate('minute', t, {millisecond: 2}) AS truncMinute,
localtime.truncate('second', t) AS truncSecond,
localtime.truncate('millisecond', t) AS truncMillisecond,
localtime.truncate('microsecond', t) AS truncMicrosecond
truncDay | truncHour | truncMinute | truncSecond | truncMillisecond | truncMicrosecond |
---|---|---|---|---|---|
|
|
|
|
|
|
Rows: 1 |
time()
Details for using the time()
function.
Getting the current ZONED TIME
time()
returns the current ZONED TIME
value.
If no time zone parameter is specified, the local time zone will be used.
Syntax:
time([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A string expression that represents the time zone. |
Considerations:
If no parameters are provided, |
RETURN time() AS currentTime
The current time of day using the local time zone is returned.
currentTime |
---|
|
Rows: 1 |
RETURN time({timezone: 'America/Los Angeles'}) AS currentTimeInLA
The current time of day in California is returned.
currentTimeInLA |
---|
|
Rows: 1 |
time.transaction()
time.transaction()
returns the current ZONED TIME
value using the transaction
clock.
This value will be the same for each invocation within the same transaction.
However, a different value may be produced for different transactions.
Syntax:
time.transaction([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN time.transaction() AS currentTime
currentTime |
---|
|
Rows: 1 |
time.statement()
time.statement()
returns the current ZONED TIME
value using the statement
clock.
This value will be the same for each invocation within the same statement.
However, a different value may be produced for different statements within the same transaction.
Syntax:
time.statement([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN time.statement() AS currentTime
currentTime |
---|
|
Rows: 1 |
RETURN time.statement('America/Los Angeles') AS currentTimeInLA
currentTimeInLA |
---|
|
Rows: 1 |
time.realtime()
time.realtime()
returns the current ZONED TIME
value using the realtime
clock.
This value will be the live clock of the system.
Syntax:
time.realtime([{timezone}])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression that represents the time zone. |
RETURN time.realtime() AS currentTime
currentTime |
---|
|
Rows: 1 |
Creating a ZONED TIME
time()
returns a ZONED TIME
value with the specified hour, minute, second, millisecond, microsecond, nanosecond and timezone component values.
Syntax:
time({hour [, minute, second, millisecond, microsecond, nanosecond, timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
The hour component will default to |
The minute component will default to |
The second component will default to |
Any missing |
The timezone component will default to the configured default time zone if |
If |
The least significant components in the set |
One or more of |
UNWIND [
time({hour: 12, minute: 31, second: 14, millisecond: 123, microsecond: 456, nanosecond: 789}),
time({hour: 12, minute: 31, second: 14, nanosecond: 645876123}),
time({hour: 12, minute: 31, second: 14, microsecond: 645876, timezone: '+01:00'}),
time({hour: 12, minute: 31, timezone: '+01:00'}),
time({hour: 12, timezone: '+01:00'})
] AS theTime
RETURN theTime
theTime |
---|
|
|
|
|
|
Rows: 5 |
Creating a ZONED TIME
from a STRING
time()
returns the ZONED TIME
value obtained by parsing a STRING
representation of a temporal value.
Syntax:
time(temporalValue)
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string representing a temporal value. |
Considerations:
|
The timezone component will default to the configured default time zone if it is omitted. |
|
|
UNWIND [
time('21:40:32.142+0100'),
time('214032.142Z'),
time('21:40:32+01:00'),
time('214032-0100'),
time('21:40-01:30'),
time('2140-00:00'),
time('2140-02'),
time('22+18:00')
] AS theTime
RETURN theTime
theTime |
---|
|
|
|
|
|
|
|
|
Rows: 8 |
Creating a ZONED TIME
using other temporal values as components
time()
returns the ZONED TIME
value obtained by selecting and composing components from another temporal value.
In essence, this allows a ZONED DATETIME
, LOCAL DATETIME
or LOCAL TIME
value to be converted to a ZONED TIME
, and for "missing" components to be provided.
Syntax:
time({time [, hour, ..., timezone]})
Returns:
|
Arguments:
Name | Description |
---|---|
|
|
|
A |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An integer between |
|
An expression that specifies the time zone. |
Considerations:
If any of the optional parameters are provided, these will override the corresponding components of |
|
Selecting a |
Selecting a |
WITH localtime({hour: 12, minute: 31, second: 14, microsecond: 645876}) AS tt
RETURN
time({time: tt}) AS timeOnly,
time({time: tt, timezone: '+05:00'}) AS timeTimezone,
time({time: tt, second: 42}) AS timeSS,
time({time: tt, second: 42, timezone: '+05:00'}) AS timeSSTimezone
timeOnly | timeTimezone | timeSS | timeSSTimezone |
---|---|---|---|
|
|
|
|
Rows: 1 |
Truncating a ZONED TIME
time.truncate()
returns the ZONED TIME
value obtained by truncating a specified temporal instant value at the nearest preceding point in time at the specified component boundary (which is denoted by the truncation unit passed as a parameter to the function).
In other words, the ZONED TIME
returned will have all components that are less significant than the specified truncation unit set to their default values.
It is possible to supplement the truncated value by providing a map containing components which are less significant than the truncation unit.
This will have the effect of overriding the default values which would otherwise have been set for these less significant components.
For example, minute
— with some value x
— may be provided when the truncation unit string is 'hour'
in order to ensure the returned value has the minute set to x
instead of the default minute (which is 1
).
Syntax:
time.truncate(unit [, temporalInstantValue [, mapOfComponents ] ])
Returns:
|
Arguments:
Name | Description |
---|---|
|
A string expression evaluating to one of the following strings: |
|
An expression of one of the following types: |
|
An expression evaluating to a map containing components less significant than |
Considerations:
Truncating time to day — i.e. |
The time zone of |
If |
If |
Any component that is provided in |
Any component that is not contained in |
If |
If |
WITH time({hour: 12, minute: 31, second: 14, nanosecond: 645876123, timezone: '-01:00'}) AS t
RETURN
time.truncate('day', t) AS truncDay,
time.truncate('hour', t) AS truncHour,
time.truncate('minute', t) AS truncMinute,
time.truncate('second', t) AS truncSecond,
time.truncate('millisecond', t, {nanosecond: 2}) AS truncMillisecond,
time.truncate('microsecond', t) AS truncMicrosecond
truncDay | truncHour | truncMinute | truncSecond | truncMillisecond | truncMicrosecond |
---|---|---|---|---|---|
|
|
|
|
|
|
Rows: 1 |
Was this page helpful?