This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results forΒ

- Neo4j
- Technical Discussions
- Neo4j Graph Platform
- Conversion DateTime

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Conversion DateTime

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-06-2019 11:14 AM

13 REPLIES 13

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-06-2019 12:41 PM

You need to give us units to work with here, a bit more information please.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-06-2019 01:08 PM

Thanks for your prompt reply

input is coming as String

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-06-2019 03:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-06-2019 06:41 PM

Sorry I did not understand your question but I am using 24HR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-07-2019 01:15 AM

You have

```
start_time: 210
end_time:30
```

What are these? Seconds? Hours? Some other unit? Show us how the calculation using these that results in 10 hours and 20 minutes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-07-2019 01:26 AM

start_time: 210 ==2hours 10 min >> 2:10 AM

end_time:30 ==0hours 30 min >>00:30 AM

other example is

start_time: 1020 ==10hours 20 min >> 10:20 AM

end_time:2020 ==20hours 20 min >>10:20 PM

difference is 10 hours

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-07-2019 03:29 AM

That's not really a common format, as this represents a combination of two values of different units (some number of hours and some number of minutes) instead of a number of a single unit. It would be better to express this either solely as a number of a single unit (minutes, seconds, or milliseconds, for example) or as a string with a delimiter between units (like "02:10").

In any case you should take a look at our native temporal values which does include ways to calculate duration between given dates / datetimes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-07-2019 03:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-07-2019 04:11 AM

I think your examples are off.

210 = 2:10 AM

30 = 12:30 AM

The time difference is 22 hours and 20 minutes, not 10 hours 20 minutes.

Only if the last value was 1230 = 12:30PM would the difference be 10 hours 20 minutes.

You need to parse it somehow, since we can't treat the number as a single time unit (since 0050 + 10 = 0100, so it's not base 10 for the digits representing minutes). You'll need to transform it to a string and split it or substring it to extract the separate values.

If it was a string rather than a number you could parse it with APOC using something like:

```
return apoc.date.parse("0210", 's', "hhmm") as secondsSinceEpoch
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-08-2019 03:45 AM

My bad if difference was wrong.

I solved to get the difference of 2 time intervals

:params time1:"2300",time2:"35"

Return Case When duration.between(Localtime(Case size($time1) when 1 then "00:0"+$time1 when 2 then "00:"+$time1 when 3 then "0"+Left($time1,1)+":"+Right($time1,2) Else Left($time1,2)+":"+Right($time1,2)end) , Localtime(Case size($time2) when 1 then "00:0"+$time2 when 2 then "00:"+$time2 when 3 then "0"+Left($time2,1)+":"+Right($time2,2) Else Left($time2,2)+":"+Right($time2,2)end)).seconds <=0 then duration.between(Localtime(Case size($time1) when 1 then "00:0"+$time1 when 2 then "00:"+$time1 when 3 then "0"+Left($time1,1)+":"+Right($time1,2) Else Left($time1,2)+":"+Right($time1,2)end) , Localtime(Case size($time2) when 1 then "00:0"+$time2 when 2 then "00:"+$time2 when 3 then "0"+Left($time2,1)+":"+Right($time2,2) Else Left($time2,2)+":"+Right($time2,2)end)).seconds +86400 Else duration.between(Localtime(Case size($time1) when 1 then "00:0"+$time1 when 2 then "00:"+$time1 when 3 then "0"+Left($time1,1)+":"+Right($time1,2) Else Left($time1,2)+":"+Right($time1,2)end) , Localtime(Case size($time2) when 1 then "00:0"+$time2 when 2 then "00:"+$time2 when 3 then "0"+Left($time2,1)+":"+Right($time2,2) Else Left($time2,2)+":"+Right($time2,2)end)).seconds end as `Flight Duration`

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-09-2019 04:31 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-14-2019 03:32 PM

I agree with Andy that the time difference between 210 and 30 is 22.2 hrs as you are following military time (24 hr format).

Since this 24 hr format here is a formula to get the correct 22.2 hrs answer:

If end date < start date:

RETURN (24 - 210 * 0.01 + 30 * 0.01) as hrs

Result: 22.2

If end date > start date: (end date - start date)

Implement this formula in your Cypher query to calculate the flight time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

β05-16-2019 12:46 AM

Nodes 2022

All the sessions of the conference are now available online

Related Content

- Neo4j: Is there a way to create a new node based on a group of nodes that meet certain criteria in Neo4j Graph Platform
- How to get nodes with a certain property at path length = 1 and also, separately, >1 in Neo4j Graph Platform
- Query performance / execution time in Neo4j Graph Platform
- Subscription generation with Point spatial type in Neo4j Graph Platform
- Neo4j GraphQL how to check if node exists before connecting to it in Drivers & Stacks