在Neo4j的Cypher查询语言中处理日期和时间有多种方法。以下是一些示例:
CREATE (e:Event {name: 'Meeting', datetime: datetime("2022-08-30T10:00:00")})
MATCH (e:Event)
WHERE e.datetime >= datetime("2022-08-01T00:00:00") AND e.datetime <= datetime("2022-08-31T23:59:59")
RETURN e
MATCH (e1:Event {name: 'Event1'}), (e2:Event {name: 'Event2'})
WITH e1, e2, duration.between(e1.datetime, e2.datetime) AS duration
RETURN e1, e2, duration.years, duration.months, duration.days, duration.hours, duration.minutes, duration.seconds
MATCH (e:Event {name: 'Meeting'})
RETURN e.datetime AS original_datetime, format(e.datetime, "yyyy-MM-dd HH:mm:ss") AS formatted_datetime
MATCH (e:Event {name: 'Meeting'})
WITH e, e.datetime + duration({days: 1}) AS new_datetime
SET e.new_datetime = new_datetime
RETURN e
领取专属 10元无门槛券
手把手带您无忧上云