cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using temportal.format to format a duration with 0 hours returns 12 hours

Please keep the following things in mind:

did you search for what you want to ask before posting?

  • Yes
RETURN apoc.temporal.format(duration("P0Y0M0W0DT0H3M30S"), 'hh:mm:ss');
=> "12:03:30"
# I would expect the return value to be 0:03:30

RETURN apoc.temporal.format(duration("P0Y0M0W0DT12H3M30S"), 'hh:mm:ss')
=> "12:03:30"
# this makes sense to me

RETURN apoc.temporal.format(duration("P0Y0M0W0DT1H3M30S"), 'hh:mm:ss')
=>"01:03:30"
# this also makes sense

RETURN apoc.temporal.format(duration("P0Y0M0W0DT13H3M30S"), 'hh:mm:ss')
=>"01:03:30"
# this throws me off again.

It's pretty clear that I'm misunderstanding something about either how durations work or how the format function works. I'm just looking for resources on where to learn this information.

I've read through the following resources:
https://neo4j.com/docs/labs/apoc/current/temporal/temporal-conversions/

https://neo4j.com/docs/labs/apoc/current/temporal/datetime-conversions/

https://neo4j.com/docs/cypher-manual/current/syntax/temporal/#cypher-temporal-durations

https://neo4j.com/docs/cypher-manual/current/functions/temporal/duration/#functions-duration-create-...

Maybe I keep overlooking something in these resources. If so, I would love for it to be pointed out to me.

1 REPLY 1

intouch_vivek
Graph Steward

Hi @es50678,

Hour is denoted as HH instead of hh.

"apoc.temporal.format(duration("P0Y0M0W0DT0H3M30S"), 'HH:mm:ss')"
"00:03:30"

"apoc.temporal.format(duration("P0Y0M0W0DT13H3M30S"), 'HH:mm:ss')"
"13:03:30"