0

I want to create a relationship in neo4j having properties as day, time, year of the current date.

how can I get the current day,month, year using cypher neo4j??

Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42
RH1212354
  • 17
  • 7

2 Answers2

2

First, Neo4j doesn't have support for DateTime type.

data

CREATE (n1:Node)-[r:RELATIONSHIP {day: 30, month: 9, year: 2015}]->(n2:Node)

read

MATCH (:Node)-[r:RELATIONSHIP]->(:Node)
RETURN r.day, r.month, r.year

Another approach could be use GraphAware TimeTree. Which is Neo4j module for representing time in Neo4j as a tree structure.

MicTech
  • 42,457
  • 14
  • 62
  • 79
0

I think you can simply store a timestamp, and then deal with it in your application:

CREATE (n1:Node)-[r:RELATIONSHIP {date:timestamp()}]->(n2:Node)

As you can see on Neo4j's documentation, cypher does actually support timestamp() method call in the query, which is the most accurate date you can store, as a long

Supamiu
  • 8,501
  • 7
  • 42
  • 76