25
Views
6
Solved
###### Exact difference of two date and time
Question
Application Type
Reactive

Hi ,

Actually i have created a request on  2020-11-08 06:27  so the difference between current date and time o should be 1 when it reaches the request time . For Example It should turn as 1 on 2020-11-09 06:27 . can someone help me .I have tried DiffDays but it is turning 1 before the time it is created

Rank: #95
Solution

Hello Ummul,

Hope you're doing well.

As far as I can tell, you want to increase your count by 1 for every completed 24 hours, right?

Since you want to also consider the minutes in your dates, you need to use DiffMinutes() Built-In function.

1) Do the DiffMinutes and divide by 1440 (minutes in a day) to return the days

`DiffMinutes(DateTime1, DateTime2) / 1440`

2) Round down to its nearest integer to retrieve only completed days. I did it using Trunc() Built-In function.

`Trunc(Result)`

You can try it out in here and see if it works as you pretend (second date should be greater than first date):

Please refer to attached OML with this implementation :)

Hope that this helps you!

Kind regards,

DiffDateTime.oml

Champion
Rank: #99
Solution

Hi,

So, you can try to make the diffHours and check if already have 24. In the diff day, it will look to the day and doesn't calculate the hours.

Maybe you can verify if DiffHours(DateTime1, DateTime2) >= 24, then 1.

Hope this can help.

Best regards,

Ricardo M Pereira

Rank: #95
Solution

Hello Ummul,

Hope you're doing well.

As far as I can tell, you want to increase your count by 1 for every completed 24 hours, right?

Since you want to also consider the minutes in your dates, you need to use DiffMinutes() Built-In function.

1) Do the DiffMinutes and divide by 1440 (minutes in a day) to return the days

`DiffMinutes(DateTime1, DateTime2) / 1440`

2) Round down to its nearest integer to retrieve only completed days. I did it using Trunc() Built-In function.

`Trunc(Result)`

You can try it out in here and see if it works as you pretend (second date should be greater than first date):