Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-05-2021 02:52 AM
I'm somewhat confused about datetime comparisons in neo4j. I have a data source with datetimeoffset (from SQL Server) It seems that datetime() with iso8601-dates with different offsets aren't comparable (at least not like in C#, JavaScript and T-SQL).
Consider the following:
with
datetime('2021-08-05T10:06:19.230+0100') as time1,
datetime('2021-08-05T11:06:19.230+0200') as time2,
datetime('2021-08-05T10:06:19.231+0100') as time1_plus_1ms
return
duration.between(time1,time2) as duration,
time1=time2,
time1<time2,
time1_plus_1ms<time2,
time1.epochMillis,
time2.epochMillis;
This yields
[
{
"duration": "P0M0DT0S",
"time1=time2": false,
"time1<time2": true,
"time1_plus_1ms<time2": false,
"time1.epochMillis": 1628154379230,
"time2.epochMillis": 1628154379230
}
]
Is this a bug? I would expect time1=time2 to be true, note the epochMillis equality. At first I thought that the comparison ignored the offset, but that's not what's happening according to the +1 ms comparison. This behavior makes no sense to me as the only meaningful way to compare two points in time is to see whether they represent the same point in time, or if not, which of them occurred earlier. C#, T-SQL and JavaScript agrees with me.
I would like to keep the offset value, avoid storing two different values, and being able to compare them in a meaningful way with indexing. If I need to format the output to create an ISO format that's fine, but searching for either time1 or time2 should match properties in both formats (it doesn't do so according to my testing). What's the best practice workaround?
Thanks 🙂
09-17-2021 07:44 AM
I have encountered the same issue in Neo 4.3.2.
This looks like a bug to me.
11-22-2022 05:44 AM - edited 11-22-2022 05:47 AM
I am having this issue with 4.4.12.
Seems really critical to me, since many of my traversals are comparing datetimes.
I posted the same question on discord yesterday, no answer.
All the sessions of the conference are now available online