Datetime issue - Import data from SQL Server

(Harvey Nguyen) #1

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.

(Ryan Boyd) #2

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.


(Harvey Nguyen) #4

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.


(Ryan Boyd) #5

Agreed that it’d be good if we could specify a datetime format string along with the type.

Will put in that request.


(Benjamin Squire) #6

I am having the same issue. Lets Can we improve datetime Function for Epoch timestamps as well?

(Yudiellhernandez) #7

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"))