Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-11-2018 12:17 AM
I am using neo4j-admin import
tool to import data from large csv files. These files are exported from SQL Server.
The problem that I am facing is different format between SQL and Neo4j:
In SQL Server, datetime field is: 2018-08-16 01:15:34.500
When I import data, it has an error: Text cannot be parsed to a DateTime
Because using neo4j import tool, I cannot use any apoc or something like that to reformat this string
How can I solve this ? (I am using Neo4j community 3.4.7)
Thanks in advance.
Solved! Go to Solution.
09-11-2018 02:14 PM
Hi Harvey,
Ah, it's probably an issue with the milliseconds there.
Suggest importing as a string into a temp property and then using Cypher to update all the nodes and set the real date-time property.
Cheers,
-Ryan
09-11-2018 02:14 PM
Hi Harvey,
Ah, it's probably an issue with the milliseconds there.
Suggest importing as a string into a temp property and then using Cypher to update all the nodes and set the real date-time property.
Cheers,
-Ryan
09-11-2018 06:41 PM
Hi Ryan,
Thanks for your reply,
So I have to use some tricks in this case. However, I think Neo4j should be enhanced to handle Datetime
well in next versions.
Thanks.
Harvey
09-13-2018 09:41 AM
Agreed that it’d be good if we could specify a datetime format string along with the type.
Will put in that request.
Cheers
Ryan
10-12-2018 02:18 PM
I am having the same issue. Lets Can we improve datetime Function for Epoch timestamps as well?
11-29-2018 12:42 PM
The issue seems to be the space between the date and the time. Replacing the space for "T" fixed the issue for me.
MATCH(n:Node) RETURN datetime( REPLACE(n.DateTime," ","T"))
10-23-2020 01:25 AM
Thanks, found this really helpful. Not sure if anyone else had the same issue, but I found replacing the space with a "T" imports this column as a string, not a datetime type. Therefore it still needs to be converted into a datetime series after.
10-24-2020 09:13 PM
Try this:
with "2018-08-16 01:15:34.500" as dte
RETURN apoc.date.format(apoc.date.parse(dte, 'ms', 'yyyy-MM-dd'), 'ms', 'yyyy-MM-dd')
result:
"2018-08-16"
During import from csv file replace 'dte' with date column say row.date.
11-04-2020 05:09 AM
Faced same issue but below code works for me without apoc .
Eg.
LOAD CSV WITH HEADERS FROM "file:///sourcepath.csv" AS csvRecord
RETURN datetime(REPLACE(SPLIT(csvRecord.dt,".")[0]," ","T"))
CSV date field dt contains "2020-01-25 16:18:24.000"
Result : "2020-01-25T 16:18:24Z" .
Hope it helps!
All the sessions of the conference are now available online