Neo4j Cypher比较Cypher查询中的日期

时间:2016-12-27 19:24:26

标签: neo4j cypher spring-data-neo4j

现在我正在使用Neo4j数据库设计一个系统,我必须能够查询节点中的Date属性是否在提供的Date之前,相等或之后。

我应该如何将Date存储在Neo4j Node属性中,以便能够与基于例如==>,{{1等简单运算符的Cypher查询进行比较}}

可以像<那样存储Date吗?它会以这种方式工作吗?如果不是,请建议更好的决定。

已更新

查询我试过没有运气:

Long timestamp

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') 已存储filterValue153.value对象java.util.Date节点属性中的Value.value

@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;

...

}

Value节点的数据库级别我有以下数据:

id: 848013
value:  1482873001556

已更新

此查询正常

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) 

但如何处理1970年1月1日00:00:00 GMT之前的日期? 也可以在日期的Cypher查询中应用=><次操作吗?

1 个答案:

答案 0 :(得分:1)

相关问题:

然而,这个问题可以追溯到2012年。从那时起,我们有APOC支持date/time conversion。这使您可以转换Javadoc of the SimpleDateFormat class

中描述的格式的日期/时间值

1970/01/01之前的日期将起作用,它们将简单地用negative numbers表示。例如:

CALL apoc.date.parseDefault('1969-07-21 02:56:15', 's')
YIELD value 

算术比较运算符(=<><,...)将适用于时间戳。