Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Not sure why this isn't calculating..

Avatar

Former Community Member

Three columns...

In time

Out Time

Total Time (calculate based on in and out entered)

           <field name="hours1" w="18.182mm" h="10.04mm" access="readOnly">

                  <ui>

                     <numericEdit>

                        <border presence="hidden">

                           <?templateDesigner StyleID aped0?></border>

                        <margin/>

                     </numericEdit>

                  </ui>

                  <font typeface="Myriad Pro"/>

                  <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>

                  <para vAlign="middle" hAlign="center"/>

                  <border>

                     <edge/>

                     <corner thickness="0.1778mm"/>

                  </border>

                  <calculate>

                     <script>if( HasValue(spec1b) &amp; HasValue(spec1a) ) then

// compute time difference in minutes

var TimeDiff = (Time2Num(spec1b.formattedValue, "h:MM A") - Time2Num(spec1a.formattedValue, "h:MM A")) / (1000 * 60)

// truncate to hours

var HourDiff = Floor(TimeDiff / 60)

// get minutes less than 60

var MinDiff = Mod(TimeDiff, 60)

// build fomatted dispaly string

Concat( Format("Z9", HourDiff), ":", Format("99",MinDiff) )

else

// if any values missing null the output

null

endif

</script>

                  </calculate>

               </field>

2 Replies

Avatar

Level 7

I'm almost ashamed to admit how long it took to figure this one out.

Your outputting the value to a numeric field. Change your field to a text field, and it works just fine.

Avatar

Former Community Member

Thank you!

On Mon, May 11, 2015 at 4:41 PM, jasotastic81 <forums_noreply@adobe.com>