Calculation of hours

Good morning people, everything fine ?

I would like to know if it is possible for you to help me calculate a difference between hours.

I have some problems to share so we can find the solution below:

Example 1: 22:00 - 00:00 => 22:00

Example 2: 21:30 - 00:30 => 21:30

Example 3: 23:59 - 03:00 => 20:59

Result I hope to achieve

Example 1 = 02:00
Example 2 = 03:00
Example 3 = 02:59

Can you help me??

@tqAkshay95 All good ? You helped me in the past, I used the same logic but I couldn’t.

Hi @Gabriel2020 ,

why aren’t you using a Date&Time difference node?

Have a nice evening,
Raffaello Barri

I tried this way too, but it returns 1320 minutes which divided by 24 hours would be 22 hours.

Follow the flow below
KNIME_project.knwf (29.8 KB)

In this case, if the first column is always day0 and the second column is always day1, you could use a column expression node to paste in front of the hour values a fake date.

01/01/2024T22:00**:00** - 02/01/2024T00:00**:00** = 2 hours as expected

Raffaello Barri

Can you help me with this knot please??

If the day of the second column is sometimes the same as the first column, you need to identify in which case it is and in which it is not. You can then use a condition inside the column expression so the second column gets “01/01/2024” in some cases and “02/01/2024” in some others, but this is up to you. The logic above still holds :slight_smile:

Would this be correct?

How can I change column 2 to the next day??

1 Like

Seems good! Sorry I can’t test it I’m away from my PC :slight_smile:

To change day there should be a node for it called “date&time shift”


1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.