Duration functions
Duration functions allow for the creation and manipulation of temporal DURATION values.
| See also Temporal values and Temporal operators. | 
duration()
| Syntax | 
 | ||
| Description | Creates a  | ||
| Arguments | Name | Type | Description | 
| 
 | 
 | 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'. | |
| 
 | 
 | A pattern used to parse the input. If a pattern is provided,  | |
| Returns | 
 | ||
| If  | 
| There is no constraint on how many components are provided. | 
| It is possible to have a  | 
| The values of the components may be expressed as decimal fractions. | 
| The values of components may be arbitrarily large. | 
| The values of components may be negative. | 
| The components of  | 
| The  | 
UNWIND [
duration({days: 14, hours:16, minutes: 12}),
duration({months: 5, days: 1.5}),
duration({months: 0.75}),
duration({weeks: 2.5}),
duration({minutes: 1.5, seconds: 1, milliseconds: 123, microseconds: 456, nanoseconds: 789}),
duration({minutes: 1.5, seconds: 1, nanoseconds: 123456789})
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 6 | 
UNWIND [
duration("P14DT16H12M"),
duration("P5M1.5D"),
duration("P0.75M"),
duration("PT0.75M"),
duration("P2012-02-02T14:37:21.545"),
duration("5 hours 6 minutes", "h 'hours' m 'minutes'")
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 6 | 
duration.between()
| Syntax | 
 | ||
| Description | Computes the  | ||
| Arguments | Name | Type | Description | 
| 
 | 
 | A temporal instant type ( | |
| 
 | 
 | A temporal instant type ( | |
| Returns | 
 | ||
| If  | 
| If  | 
| If  | 
| If  | 
UNWIND [
duration.between(date("1984-10-11"), date("1985-11-25")),
duration.between(date("1985-11-25"), date("1984-10-11")),
duration.between(date("1984-10-11"), datetime("1984-10-12T21:40:32.142+0100")),
duration.between(date("2015-06-24"), localtime("14:30")),
duration.between(localtime("14:30"), time("16:30+0100")),
duration.between(localdatetime("2015-07-21T21:40:32.142"), localdatetime("2016-07-21T21:45:22.142")),
duration.between(datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/Stockholm'}), datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/London'}))
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 7 | 
duration.inDays()
| Syntax | 
 | ||
| Description | Computes the  | ||
| Arguments | Name | Type | Description | 
| 
 | 
 | A temporal instant type ( | |
| 
 | 
 | A temporal instant type ( | |
| Returns | 
 | ||
| If  | 
| If  | 
| If  | 
| If  | 
| Any difference smaller than a whole day is disregarded. | 
| Get the total number of days in a  | 
UNWIND [
duration.inDays(date("1984-10-11"), date("1985-11-25")),
duration.inDays(date("1985-11-25"), date("1984-10-11")),
duration.inDays(date("1984-10-11"), datetime("1984-10-12T21:40:32.142+0100")),
duration.inDays(date("2015-06-24"), localtime("14:30")),
duration.inDays(localdatetime("2015-07-21T21:40:32.142"), localdatetime("2016-07-21T21:45:22.142")),
duration.inDays(datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/Stockholm'}), datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/London'}))
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 6 | 
duration.inMonths()
| Syntax | 
 | ||
| Description | Computes the  | ||
| Arguments | Name | Type | Description | 
| 
 | 
 | A temporal instant type ( | |
| 
 | 
 | A temporal instant type ( | |
| Returns | 
 | ||
| If  | 
| If  | 
| If  | 
| If  | 
| Any difference smaller than a whole month is disregarded. | 
| Get the total number of months in a  | 
UNWIND [
duration.inMonths(date("1984-10-11"), date("1985-11-25")),
duration.inMonths(date("1985-11-25"), date("1984-10-11")),
duration.inMonths(date("1984-10-11"), datetime("1984-10-12T21:40:32.142+0100")),
duration.inMonths(date("2015-06-24"), localtime("14:30")),
duration.inMonths(localdatetime("2015-07-21T21:40:32.142"), localdatetime("2016-07-21T21:45:22.142")),
duration.inMonths(datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/Stockholm'}), datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/London'}))
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 6 | 
duration.inSeconds()
| Syntax | 
 | ||
| Description | Computes the  | ||
| Arguments | Name | Type | Description | 
| 
 | 
 | A temporal instant type ( | |
| 
 | 
 | A temporal instant type ( | |
| Returns | 
 | ||
| If  | 
| If  | 
| If  | 
| If  | 
| Get the total seconds of days in a  | 
UNWIND [
duration.inSeconds(date("1984-10-11"), date("1984-10-12")),
duration.inSeconds(date("1984-10-12"), date("1984-10-11")),
duration.inSeconds(date("1984-10-11"), datetime("1984-10-12T01:00:32.142+0100")),
duration.inSeconds(date("2015-06-24"), localtime("14:30")),
duration.inSeconds(datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/Stockholm'}), datetime({year: 2017, month: 10, day: 29, hour: 0, timezone: 'Europe/London'}))
] AS aDuration
RETURN aDuration| aDuration | 
|---|
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| Rows: 5 |