I have a attribute beginDate
in all nodes labeled as laws
, but I would like to query and return all nodes that the value isn`t a date - to check if the system has made a mistake in any situation - .
Therefore the pattern is a date, the attribute beginDate
is safe as a string YYYY-mm-dd
.
I`m thinking something like. :
match (l:laws) where l.apoc.date.isdate(l.beginDate) return l.name, l.beginDate
I`m using Neo4j 4.2.4 1,5 k of nodes.
You can use this APOC function: apoc.meta.cypher.isType
Ref: https://neo4j.com/labs/apoc/4.3/overview/apoc.meta/apoc.meta.cypher.isType/
For example:
RETURN apoc.meta.cypher.isType(date(), "DATE") AS output; will return True
Thus:
match (l:laws) where apoc.meta.cypher.isType(l.beginDate, "DATE") return l.name, l.beginDate
Will give you records with beginDate is date format.
if beginDate is datetime, then use DATE_TIME in the 2nd parameter.
Update: if you want to get records where beginDate is not date then
match (l:laws) where NOT apoc.meta.cypher.isType(l.beginDate, "DATE") return l.name, l.beginDate