Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-27-2020 04:20 AM
Hi,
I need to store input string 23:12:58 as duration in Neo4j node properties.
Like:
Match(n:Per{consumedTime:duration('23:12:58')})
Regards
Vivek
Solved! Go to Solution.
01-27-2020 04:38 AM
To create duration from a string: https://neo4j.com/docs/cypher-manual/current/functions/temporal/duration/#functions-duration-create-...
Format to use: https://neo4j.com/docs/cypher-manual/current/syntax/temporal/#cypher-temporal-specifying-durations
Maybe easier to create it with components: https://neo4j.com/docs/cypher-manual/current/functions/temporal/duration/#functions-duration-create-...
duration({hours: 23, minutes:12, seconds: 58})
?
01-27-2020 04:38 AM
To create duration from a string: https://neo4j.com/docs/cypher-manual/current/functions/temporal/duration/#functions-duration-create-...
Format to use: https://neo4j.com/docs/cypher-manual/current/syntax/temporal/#cypher-temporal-specifying-durations
Maybe easier to create it with components: https://neo4j.com/docs/cypher-manual/current/functions/temporal/duration/#functions-duration-create-...
duration({hours: 23, minutes:12, seconds: 58})
?
01-27-2020 04:40 AM
RETURN duration({hours: 23, minutes: 12, seconds:12}) as duration
╒══════════════╕
│"duration" │
╞══════════════╡
│"P0M0DT83532S"│
└──────────────┘
WITH duration({hours: 23, minutes: 12, seconds:12}) as duration
MATCH (n:Per {consumedTime: duration})
RETURN n
01-27-2020 04:50 AM
I should store it as 'PT23H12M58S' string in this format, then you can do calculations like this:
RETURN duration('PT23H12M58S').seconds;
It will give you the duration in seconds (83578 s).
01-27-2020 10:19 AM
Thanks a lot it worked.
All the sessions of the conference are now available online