Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

time over 24hr not calculating

Avatar

Level 2

if (HasValue(startsamplingtime) and HasValue(endsamplingtime)) then

   var millisecondsPerMinute = 1000 * 60;

   var millisecondsPerHour = millisecondsPerMinute * 60;

   var interval = Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS");

  

    // Calculate the hours, minutes, and seconds.

   var hours = Floor(interval / millisecondsPerHour );

   interval = interval - (hours * millisecondsPerHour );

   var minutes = Floor(interval / millisecondsPerMinute );

   interval = interval - (minutes * millisecondsPerMinute );

   var seconds = Floor(interval / 1000 );

        

   Concat( Format("Z9", hours), ":", Format("99",minutes), ":", Format("99", seconds))

endif

Need to incorporate date to make this calculation work right for over 24hrs. Don't want to have a date/time field if possible.  Would like to keep the fields separate.  For example:

Start Date 01/02/2014       Start Time 12:23:52  

End Date 01/03/2014        End Time   01:23:52

Total Time 1:00:00

Thanks

0 Replies

Avatar

Level 10

Hi,

check this thread. It's about time calculations including those with times past midnight.

https://forums.adobe.com/message/4054814#4054814#4054814

Avatar

Level 2

So I simplified my script to:

if (HasValue(startsamplingtime) and HasValue(endsamplingtime)) then

calcsoaktime = Abs(Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS"))/(60*60*1000);

 

else calcsoaktime = 24 - Abs(Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS"))/(60*60*1000);

endif

The only problem is that I want the calcsoaktime to be formatted in HH:MM:SS.  I have made the display and data pattern both this format and it is ignoring because calculated.  The number is coming out in decimal minutes.  How do I format a calculated field?

Thanks