CSV中给定的日期格式为``(星期五)2018年1月9日(32)''。这应该作为日期列输入数据库,以允许按日期排序。如何在插入时将上述格式转换为Neo4j日期格式?
答案 0 :(得分:0)
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;
说明:
╒══════════╕
│"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;
答案 1 :(得分:0)
假定日期子字符串始终从输入字符串的偏移量6开始,这将返回01 Jan 1970
的日期偏移量,足以比较日期:
WITH '(Fri) 09 Jan 2018 (32)' as s
RETURN apoc.date.parse(SUBSTRING(s, 6, 11), 'd', "dd MMM yyyy") as date;