Reputation: 481
The given date format in CSV is '(Fri) 09 Jan 2018 (32)'. This should feed to database as a date column to allow order by date. How could convert above format to Neo4j date format at the insertion time ?
Upvotes: 0
Views: 156
Reputation: 67044
Assuming the date substring always starts at offset 6 in the input string, this will return the date offset from 01 Jan 1970
, which is adequate for comparing dates:
WITH '(Fri) 09 Jan 2018 (32)' as s
RETURN apoc.date.parse(SUBSTRING(s, 6, 11), 'd', "dd MMM yyyy") as date;
Upvotes: 0
Reputation: 1304
WITH '(Fri) 09 Jan 2018 (32)' as inputString
WITH split(inputString, ' ') as parts
WITH parts[1] + ' ' + parts[2] + ' ' + parts[3] AS concatDate
RETURN apoc.date.parse(concatDate, 's',"dd MMM yyyy") as date;
Explanation:
╒══════════╕
│"date" │
╞══════════╡
│1515456000│
└──────────┘
WITH '(Fri) 09 Jan 2018 (32)' as inputString
WITH split(inputString, ' ') as parts
WITH reduce(s = "", x IN parts[1..4] | s + x) AS concatDate
RETURN apoc.date.parse(concatDate, 's',"ddMMMyyyy") as date;
Upvotes: 1