0

I ran CALL apoc.date.parseDefault('1969-07-21 02:56:15', 's') YIELD value in the browser of neo4j. But it does not work.

The error is: There is no procedure with the name apoc.date.parseDefault registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

I could run CALL apoc.load.json(url) YIELD value or CALL apoc.help("apoc") work without any problem.

(Question originally asked in the comment here)

Community
  • 1
  • 1
Aqqqq
  • 816
  • 2
  • 10
  • 27

1 Answers1

4

Since Neo4j 3.1 introduced user-defined functions, several APOC procedures have migrated over, including date parsing. Additionally, these functions support optional parameters, so there is no need for a separate parseDefault() function, it's been dropped since parse() handles it just fine.

Try this instead:

RETURN apoc.date.parse('1969-07-21 02:56:15', 's') as date

You can call functions inline without needing to use CALL or YIELD.

Unfortunately some of the documentation is lagging a bit in reflecting these conversions. While the date/time functions look up-to-date, some of the examples are still referencing the removed procedures rather than referencing current functions.

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
  • Do you know how to parse the date in such form: '1969-07-21T02:56:15'? I have the same problem as described here:http://www.markhneedham.com/blog/2017/03/06/neo4j-apoc-date-parse-java-lang-illegalargumentexception-illegal-pattern-character-t-java-text-parseexception-unparseable-date-2012-11-12t084615z/ – Aqqqq Apr 18 '17 at 07:58
  • The solution is in the blog post, put quotes around the T like so: `RETURN apoc.date.parse('1969-07-21T02:56:15', 's', "yyyy-MM-dd'T'HH:mm:ss") as date` – InverseFalcon Apr 18 '17 at 08:11
  • What should I do if I want to use the result of the parsing later in the query? As RETURN could only be used at the end of a query, one can't use it in the middle of the query to deliver the result. And one could not use CALL apoc..... YIELD value as value1 either.(Error: There is no procedure with the name `apoc.date.parse` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed) – Aqqqq Apr 18 '17 at 08:53
  • Take a look at the [WITH](https://neo4j.com/docs/developer-manual/current/cypher/clauses/with/) clause. Among its uses, WITH is used to join different parts of a query together, and change what variables are in scope. `WITH apoc.date.parse('1969-07-21T02:56:15', 's', "yyyy-MM-dd'T'HH:mm:ss") as date ...` – InverseFalcon Apr 18 '17 at 13:54
  • Thanks. I just found that `apoc.date.parse('1969-07-21T02:56:15', 's', "yyyy-MM-dd'T'HH:mm:ss")` could be used directly as an expression in the place of value. – Aqqqq Apr 18 '17 at 14:09