Today I Learned

A Hashrocket project

Compare Dates in Neo4j.rb

Neo4j.rb stores dates as timestamps so you will have to convert your date object into a timestamp.

To convert a date object into a timestamp first convert to utc time and then to integer:

Date.current.to_time(:utc).to_i

And in your cypher query you are safe to use the comparison operators:

where('post.published_at <= ?', Date.current.to_time(:utc).to_i)
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. Contact us and find out how we can help you.