Time Calculate

0
hello everyone,    I am trying to calculate time using following function.  How can I use decimal here? The start time is of type Date&Time. I try to add it with a decimal (e.g. 1.5 as 1Hour 30 Min) and get a EndTime also with Date&Time as output.  Thx  
asked
3 answers
1

I think you'll have to do some calculations, depending on the possible values for the decimal and how precise you want to be, and use the floor or ceil function to force an integer instead of a decimal as the outcome.

E.g.:

addMinutes($ReM/StartTime, floor($ActivProgram/Duration * 60))

or

addSeconds($ReM/StartTime, floor($ActivProgram/Duration * 60 * 60))

or even

addMilliSeconds($ReM/StartTime, floor($ActivProgram/Duration * 60 * 60 * 1000))

answered
1

Hi John,

 

What you could to is convert your hours to minutes first by multiplying your value to 60 and then use the AddMinutes function instead of AddHours. Create an integer value that multiplies your decimal value with 60 and then use that value in the AddMinutes function. Add the round function before, so it would look like: round(1.5 * 60). You could also use floor or ceil depending on your use case.

For a more precise approach, you could multiply the decimal value to 3600 to get seconds and then use the AddSeconds function.

 

I hope this helps!

 

answered
0

so nice! thanks all of you!

answered