Converting DateTime to Epoch milliseconds using Cypher in Neo4J

北城余情 提交于 2021-01-27 15:50:47

问题


I'm running a query using Cypher in Neo4J where I have to compare a createdAt property of a node against a given time unit in Epoch milliseconds. This createdAt property is a string in the DateTime format, which is defined as -

DateTime

date with a precision of miliseconds, encoded as a string with the following format: yyyy-mm-ddTHH:MM:ss.sss+0000, where yyyy is a four-digit integer representing the year, the year, mm is a two-digit integer representing the month and dd is a two-digit integer representing the day, HH is a two-digit integer representing the hour, MM is a two digit integer representing the minute and ss.sss is a five digit fixed point real number representing the seconds up to milisecond precision. Finally, the +0000 of the end represents the timezone, which in this case is always GMT.

Here are a couple of values of this property - 2011-03-21T19:32:38.295+0000, 2012-03-09T17:59:05.367+0000.

I came across the Temporal Values documentation on Neo4j, but couldn't find a way to perform the conversion.

When I execute some of the given examples, like this -

RETURN datetime('2015-06-24T12:50:35.556+0100') AS theDateTime

I get the error -

Neo.ClientError.Statement.SyntaxError: Unknown function 'datetime' (line 1, column 16 (offset: 15))

Would appreciate any help!


回答1:


The temporal functions were added in neo4j version 3.4.0, and I have verified that your query works in that version.

Make sure you are using an appropriately recent version of neo4j.



来源:https://stackoverflow.com/questions/51168792/converting-datetime-to-epoch-milliseconds-using-cypher-in-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!