Right now I'm designing a system with Neo4j database where I have to be able to have a query check if a Date
property in a node is before, equal or after the provided Date
.
How should I store the Date
inside of Neo4j Node property to be able to do a comparison with Cypher query based for example on simple operators like ==
, >
, <
Is it okay to store Date
like Long timestamp
? Will it work this way ? If no, please suggest a better decision.
UPDATED
Queries I have tried with no luck:
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = '60305027689736')
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = 'Mon Dec 27 22:35:56 EET 3880')
Where filterValue153.value
has been stored like java.util.Date
object in Value.value
node property
@NodeEntity
public class Value extends Authorable {
public final static String NODE_NAME = "Value";
private final static String SET_FOR = "SET_FOR";
private final static String SET_ON = "SET_ON";
@Relationship(type = SET_FOR, direction = Relationship.OUTGOING)
private Decision decision;
@Relationship(type = SET_ON, direction = Relationship.OUTGOING)
private Characteristic characteristic;
private Object value;
...
}
at database level for Value
node I have a following data:
id: 848013
value: 1482873001556
UPDATED
This query works fine
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} MATCH (childD)<-[:SET_FOR]-(filterValue153:Value)-[:SET_ON]->(filterCharacteristic153:Characteristic) WHERE id(filterCharacteristic153) = 153 WITH filterValue153, childD, ru, u WHERE (filterValue153.value = 60305030539682)
but how to deal with dates prior January 1, 1970, 00:00:00 GMT ?
Also is it okay to apply =
, >
, <
operations in this Cypher query on dates ?