18
Views
7
Solved
###### Different between two times
Question

Hi Friends,

I am having two-time variable when I get different between from and to time, its not coming as expected, please anyone can help for the below scenario.

For example:

My start time is 3:00:22 and my end time is 03:27:11 so here I am using to get the diff between these two time is

NewTime(DiffHours(StartTime,EndTime),Mod(DiffMinutes(StartTime,EndTime),60),Mod(DiffSeconds(StartTime,EndTime),60)

its giving 00:27:49 instead of 00:26:49, can any one help on these scenario.

Thank you.

Rank: #89
Solution

Hi Balaji,

DiffMinutes return only in minute diffrence.

Use this expression-

```NewTime((DiffSeconds(StartTime,EndTime)/3600),Mod(DiffSeconds(StartTime,EndTime)/60,60),Mod(DiffSeconds(StartTime,EndTime),60))

```

It will give you actual result.

Regards

Rahul

MVP
Rank: #67

Hello Balaji.

Let's see this step by step:

• DiffHours between 3 and 3 is 0.
• DiffMinutes between 3:0 and 3:27 is 27 (the seconds are ignored if you check the documentation).
• DiffSeconds between 3:00:22 and 3:27:11 is 1609. Mod(1609,60)=49

0 hours, 27 minutes and 49 seconds.So the value is right.

The ideal way is to work with seconds only NewTime(0,0,DiffSeconds(StartTime,EndTime)) will give you the right time.

Rank: #89

Welcome @Balaji..

Cheers

MVP
Rank: #67

No problem.

A small correction on my formula: it is not NewDate(0,0,DiffSeconds(Time1,Time2)). Because the number of seconds in invalid.