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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Not sure why this isn\'t calculating..

Avatar

Level 1

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

Level 1

Thank you!

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