Write, Bureaucrats, Administrators
275
edits
Line 59: | Line 59: | ||
== Examples == | == Examples == | ||
===== Example 1 ===== | ===== Example 1: Sum ===== | ||
Entries contain fields: Price, Count<br /> | Entries contain fields: Price, Count<br /> | ||
We add a calculating field "Sum" by using the following expression: | We add a calculating field "Sum" by using the following expression: | ||
<source lang="java">#{Price}*#{Count}</source> | <source lang="java">#{Price}*#{Count}</source> | ||
===== Example 2 ===== | ===== Example 2: Percentage ===== | ||
Entries contain fields: Count, Total<br /> | Entries contain fields: Count, Total<br /> | ||
We add a calculating field "Percentage" by using the following expression: | We add a calculating field "Percentage" by using the following expression: | ||
<source lang="java">(#{Count } / #{ Total }) * 100</source> | <source lang="java">(#{Count } / #{ Total }) * 100</source> | ||
===== Example 3 ===== | ===== Example 3: Duration ===== | ||
Entries contain fields: StartDateTime, EndDateTime<br /> | Entries contain fields: StartDateTime, EndDateTime<br /> | ||
We add a calculating field "Duration" by using the following expression (result is number seconds): | We add a calculating field "Duration" by using the following expression (result is number seconds): | ||
<source lang="java">#{EndDateTime} - #{StartDateTime}</source> | <source lang="java">#{EndDateTime} - #{StartDateTime}</source> | ||
===== Example 4 ===== | ===== Example 4: Days ===== | ||
Entries contain fields: StartDate, EndDate<br /> | Entries contain fields: StartDate, EndDate<br /> | ||
We add a calculating field "Days" by using the following expression: | We add a calculating field "Days" by using the following expression: | ||
<source lang="java">datediff(#{EndDate} , #{StartDate})</source> | <source lang="java">datediff(#{EndDate} , #{StartDate})</source> | ||
===== Example 5 ===== | ===== Example 5: Days left ===== | ||
Entries contain fields: Time<br /> | Entries contain fields: Time<br /> | ||
We add a calculating field "Days left" by using the following expression: | We add a calculating field "Days left" by using the following expression: | ||
<source lang="java">if( #{Time} > now() , rint((#{Time} - now())/(60*60*24)) , 'in the past')</source> | <source lang="java">if( #{Time} > now() , rint((#{Time} - now())/(60*60*24)) , 'in the past')</source> | ||
===== Example 6 ===== | ===== Example 6: References ===== | ||
There’s library Order – with orders and library Item – with items. Library Order contains a link to library Item and numeric field Count. | There’s library Order – with orders and library Item – with items. Library Order contains a link to library Item and numeric field Count. | ||
Library Item contains field Price.<br /> | Library Item contains field Price.<br /> |