Duration in Minutes

Working with dates and times

Calculate minutes between two datetime values

Write a query to retrieve this Test node and calculate the number of minutes between datetime1 and datetime2.

Enter the number of minutes:

  • ✓ 400

Hint

Did you create the Test node with the datetime1 and datetime2 values?

Use duration.between and extract the minutes value.

How many minutes are between datetime1 and datetime2?

Once you have entered the answer, click the Try Again button below to continue.

Solution

Before you calculate the duration, make sure you have executed this code to create or update the Test node:

cypher
MERGE (x:Test {id: 1})
SET
x.date = date(),
x.datetime = datetime(),
x.timestamp = timestamp(),
x.date1 = date('2022-04-08'),
x.date2 = date('2022-09-20'),
x.datetime1 = datetime('2022-02-02T15:25:33'),
x.datetime2 = datetime('2022-02-02T22:06:12')
RETURN x

You can run the following query to find the answer:

cypher
// calculate the duration in minutes
MATCH (x:Test)
RETURN duration.between(x.datetime1,x.datetime2).minutes

How many minutes are between datetime1 and datetime2?

Once you have entered the answer, click the Try Again button below to continue.

Summary

In this challenge, you wrote a query to return the duration in minutes between two datetime values.

In the next module, you will learn about graph traversal during a query.