Working with Dates and Durations
Use Neo4j temporal types to filter, compute, and search date-based data
In this 35-minute lab, you will learn
The movies database stores release years and birth years as plain integers. These values work for simple lookups, but they cannot answer questions about time spans, date ranges, or relative ordering without manual arithmetic scattered across your queries.
In this lab, you will use Neo4j's built-in temporal types to convert those raw integers into proper date values, truncate dates for grouping and index-friendly comparisons, compute durations between events, and combine these techniques to build date range searches. By the end, you will have written a query that finds movies by actor and release window using temporal arithmetic.
You will work with the movies dataset: a graph of Movie nodes (with title, released, and tagline properties) and Person nodes (with name and born properties), connected by ACTED_IN and DIRECTED relationships.
Temporal types
Understand Neo4j date, datetime, time, localtime, and localdatetime types and how to create them.
Date conversion and truncation
Convert integer year properties into proper date values and truncate dates for grouping and index-friendly comparisons.
Durations and arithmetic
Create durations, compute time spans between dates with duration.between(), and perform date arithmetic with + and - operators.
Date range searches
Combine date conversion, truncation, and duration arithmetic to build temporal range queries that leverage indexes.
Posts from the GraphAcademy blog.
Writing Cypher Queries That Don't Lose Your Data
The query trap that hides your newest data, and the query shape that brings it back.
SQL to Cypher - 10 Queries You Already Know
You already know how to write these queries. This article shows you what they look like when the joins go away.
TIL: Cypher has a format() function for dates and times
A deprecation warning taught me that Cypher now formats dates, times, and durations natively. No APOC required.