Handling Datetime in Cypher for Neo4J?

I have the datetime field in the property of the node, I can return the values, but not working for WHERE clause

If I use where for specific date its not returning

Also i want to return the last 3 days transaction, i tried datetime() minus datetime('2020-03-02T00:01:44.68Z'), i couldn't return

2 Answers

Yes, Found it, datetime field need casting to filter the date or datetime Thanks

one thing i couldn't is to get the last 3 days, i have to check the t.TxnDateTime and the current datetime() difference of 3 days

As documented, comparisons can only be done between temporal instant values of the same type. For example, a date cannot be compared to a datetime, but it can be compared to another date.

Also, you can use an appropriate duration function (such as duration.inSeconds()) to subtract 2 temporal values, creating a duration. And you can then access a component of that duration using an appropriate property (such as seconds).

For example, this query:

WITH duration.inSeconds(
  date({year:2000, month:1, day:1}),
  date({year:2000, month:1, day:2})) AS durationInSeconds
RETURN durationInSeconds, durationInSeconds.seconds

returns:

╒═══════════════════╤═══════════════════════════╕
│"durationInSeconds"│"durationInSeconds.seconds"│
╞═══════════════════╪═══════════════════════════╡
│"P0M0DT86400S"     │86400                      │
└───────────────────┴───────────────────────────┘

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest