cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Returning results between 2 dates

Hi, I'm new in Neo4j, and I'm working and searching to learn more about it and graph usage.

I made this querry but it says that I have an error, anyone can help me so I can move on? What I want to know is what some user has bought between 2 dates (I used "EventDate" because its an existing property, with "date" it has the same result - error):

<
MATCH (ee:User) - [:Buy] - (Product)
WHERE ee.UserId = "u20784378"
WITH eventDate("2018-04-08") AS startDate, eventDate("2018-07-08") AS endDate
RETURN Product

Thanks 🙂

7 REPLIES 7

ameyasoft
Graph Maven

Try this:

Assuming eventDate is a property of Product

MATCH (ee:User) - [:Buy] - (p:Product)
WHERE ee.UserId = "u20784378"
AND p.eventDate >= "2018-04-08" AND p.eventDate <= "2018-07-08"
RETURN p;

Note also you can chain the inequalities:

MATCH (ee:User) - [:Buy] - (p:Product)
WHERE ee.UserId = "u20784378"
AND "2018-04-08" <= p.eventDate <= "2018-07-08"
RETURN p;

Thanks all, and thanks for the link

Tried, but eventDate is a property of a relationship between User and Product, in this case is "Buy". So it doesn't work 😞

Try this:
MATCH (ee:User) - [r:Buy] - (p:Product)
WHERE ee.UserId = "u20784378"
AND "2018-04-08" <= r.eventDate <= "2018-07-08"
RETURN p;

Thank you for your help