Vineel
Vineel

Reputation: 1788

Neo4j DATE Data Types

I am using Neo4j 2.0 version. Suppose, I have lot of records which have date as one of their fields and if we need to support lot of queries like count of records between two specific dates etc, I think that I may have tpo index all the records by Date field. Is this correct? Then., how do I do it. All nodes of the type "RECORD" need to be indexed dy date. How can I achieve this? Please note that Date is a not unique field. And how do I even store Date property in the records. Is Date supported in CYPHER or Neo4j. How do I sort the records by Date field?

Upvotes: 13

Views: 13023

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

Dates as values for properties are not directly supported. Depending on your usecase you typically store the millis since epoch (aka date.getTime()) in a long property or a string representation using a DateFormatter (when being in Java land).

The long representation is better suited if you intend to do any math operation with dates. String is better if you want your properties being human readable without any conversion.

When requiring indexes on dates the easiest approach would be storing millis since epoch and apply a schema index on this.

Upvotes: 20

Related Questions