I am computing the differences between datetime1 and datetime2 in minutes. First created a test node
MERGE (x:Test {id: 1})
SET
x.date = date(),
x.datetime = datetime(),
x.timestamp = timestamp(),
x.date1 = date('2022-04-08'),
x.date2 = date('2022-09-20'),
x.datetime1 = datetime('2022-02-02T15:25:33'),
x.datetime2 = datetime('2022-02-02T22:06:12')
RETURN x
I know the correct query is:
match (x:Test)
return duration.between(x.datetime1, x.datetime2).minutes
But hy the following will return different result compare to the above?
match (x:Test)
return duration.inSeconds(x.date1, x.date2).seconds/60
My understanding is the first query produces the time differences in minutes and the second query produces the time differences in minutes because I divided the seconds results by 60.
The parameters in your queries are different:
match (x:Test)
return duration.inSeconds(x.date1, x.date2).seconds/60 <--- date1 and date2 here
match (x:Test)
return duration.between(x.datetime1, x.datetime2).minutes <--- datetime1 and datetime2 here
Try this, it will give the same output:
match (x:Test)
return duration.inSeconds(x.datetime1, x.datetime2).seconds/60 <--- date1 and date2 here