In the following example I have two objects on input. I want to select the one where duration between start
and end
is more that one day -> I expect object called threeDays
to be returned.
How to write such condition in jsonpath?
start
and end
are date times.
I am using Postres 13.
SELECT jsonb_path_query_array_tz('[
{ "name" : "oneDay",
"start": "2021-07-02 00:00:00",
"end": "2021-07-03 00:00:00"
},
{ "name" : "threeDays",
"start": "2021-07-15 00:00:00",
"ende": "2021-07-18 00:00:00"
}
]'::jsonb, '$[*] ? (
@.end.datetime() - @.start.datetime() > 1day <----- ???
).name');