cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot construct date time from: NO_VALUE (Failure when processing file

hi_joshi
Node

Hello there,
I am loading the data from a sample CSV into Employee. The CSV has 2 columns - birthdate and hiredate. The code is like this -

load csv with headers from 'file:///northwind/employees2.csv' as row
merge(c:Country {country : row.country})
merge(e:Employee {
employeeId:toInteger(row.employeeID)
,firstName : row.firstName
,birthDate : date(datetime({epochmillis:apoc.date.parse(row.birthdate, 'ms', 'yyyy-MM-dd')}))
,hireDate : date(datetime({epochmillis:apoc.date.parse(row.hiredate, 'ms', 'yyyy-MM-dd')}))
})
create (e) - [:HAS_COUNTRY {countryName:c.country}] -> (c);

Getting following error -

Cannot construct date time from: NO_VALUE (Failure when processing file '/C:/neo4j423/import/northwind/employees.csv' on line 2.)

I tried with just 1 row in the csv. birthdate and hiredate both are available.
If I try with a hardcoded value like '2001-01-01', the code works just fine.

Any ideas what could be wrong?

Thanks

Manoj Joshi

5 REPLIES 5

asharpe
Node Clone

I have the same issue. Did you end up solving it?
It seems that the datetime() function requires a hardcoded timestamp value rather than a variable or alias

ameyasoft
Graph Maven

Please post the date value as in your .csv file so that I can suggest a solution

@ameyasoft I'm not sure about OP's value, but mine is 1609283699032, and the query giving me the

Cannot construct date time from: NO_VALUE error is the one below

match (n:MyNode) 
with date(datetime({epochmillis: n.timestamp})) as r 
return r

where n.timestamp is the value 1609283699032

.csv file stores all values as strings. While importing, one needs to use toInteger function and that stores the property value as integer. Here is the workaround sample:

with '1609283699032' as tme
with date(datetime({epochmillis: toInteger(tme)})) as r
return r

Result: "2020-12-29"

@ameyasoft thank you!

For anyone who reads this in the future:
After trying out ameyasoft's solution, I discovered that passing in a string timestamp could also produce this different error: Cannot construct date time from: String("1609283699032") , which is more informative than the first error I got.
After that, I also realized that my error was coming from me reading in null values for n.timestamp, so I just added a WHERE n.timestamp IS NOT NULL, and it fixed the problem

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.