<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://doc-en-mirror.openflyers.com/index.php?action=history&amp;feed=atom&amp;title=CommonFormula</id>
	<title>CommonFormula - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://doc-en-mirror.openflyers.com/index.php?action=history&amp;feed=atom&amp;title=CommonFormula"/>
	<link rel="alternate" type="text/html" href="https://doc-en-mirror.openflyers.com/index.php?title=CommonFormula&amp;action=history"/>
	<updated>2026-05-01T09:01:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://doc-en-mirror.openflyers.com/index.php?title=CommonFormula&amp;diff=237&amp;oldid=prev</id>
		<title>imported&gt;Claratte: Text replacement - &quot;&lt;php&gt;&quot; to &quot;&lt;syntaxhighlight lang=&quot;php&quot;&gt;&quot;</title>
		<link rel="alternate" type="text/html" href="https://doc-en-mirror.openflyers.com/index.php?title=CommonFormula&amp;diff=237&amp;oldid=prev"/>
		<updated>2024-08-12T18:53:07Z</updated>

		<summary type="html">&lt;p&gt;Text replacement - &amp;quot;&amp;lt;php&amp;gt;&amp;quot; to &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;All the functions are not available in all the OF versions and in all the formula types:&lt;br /&gt;
*flight time formula, &lt;br /&gt;
*pricing management formula, &lt;br /&gt;
*recent experience formula,&lt;br /&gt;
*accounting formula&lt;br /&gt;
&lt;br /&gt;
'''See [[AdminDoc2.1]] or [[AdminDoc3]] to check the availability in the appropriated section'''&lt;br /&gt;
&lt;br /&gt;
=conditional processing=&lt;br /&gt;
 (test) ? true-case : false-case&lt;br /&gt;
&lt;br /&gt;
=conditional processing with operator OR/AND=&lt;br /&gt;
&lt;br /&gt;
==OR operator==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;( test1 OR test2 ) ? true-case : false-case&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is also available in OpenFlyers 4.0 and above:&lt;br /&gt;
&amp;lt;pre&amp;gt;( test1 || test2 ) ? true-case : false-case&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==AND operator==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;( test1 AND test2 ) ? true-case : false-case&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is also available in OpenFlyers 4.0 and above:&lt;br /&gt;
&amp;lt;pre&amp;gt;( test1 &amp;amp;&amp;amp; test2 ) ? true-case : false-case&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=functions=&lt;br /&gt;
&lt;br /&gt;
==abs(a)==&lt;br /&gt;
return the absolute value of a&lt;br /&gt;
&lt;br /&gt;
==addTime(%SOME_DATE, %SOME_TZ)==&lt;br /&gt;
return %SOME_DATE with added time depending of %SOME_TZ&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;addTime(%NOW_DATE, %USER_TZ) returns the current date converted to user timezone by adding timezone time difference&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : This function no longer exists on OF version 3.0 and later.&lt;br /&gt;
&lt;br /&gt;
==changeTime(%SOME_DATE, 'year', 'month', 'day')==&lt;br /&gt;
return %SOME_DATE with changed values for year, month and day&lt;br /&gt;
&lt;br /&gt;
Date given as parameter and returned date are in UTC.&lt;br /&gt;
Possible values for year, month, day parameters are :&lt;br /&gt;
*&amp;quot;0&amp;quot; to not changing year/month/day&lt;br /&gt;
*&amp;quot;+X&amp;quot; to increment year/month/day by X&lt;br /&gt;
*&amp;quot;-X&amp;quot; to decrement year/month/day by X&lt;br /&gt;
*&amp;quot;X&amp;quot; to set year/month/day to X&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;changeTime( '2011-05-15', '0', '0', '0' ) returns 2011-05-15, the date stays unchanged&lt;br /&gt;
changeTime( '2011-05-15', '0', '-test', '0' ) returns 2011-05-15, the date stays unchanged because the parameter 'month' isn't valid&lt;br /&gt;
changeTime( '2011-05-15', '0', '-2', '0' ) returns 2011-03-15, month was decremented by 2&lt;br /&gt;
changeTime( '2011-05-15', '0', '+2', '0' ) returns 2011-07-15, month was incremented by 2&lt;br /&gt;
changeTime( '2011-05-15', '0', '2', '0' ) returns 2011-02-15, month was set to 2 (February)&lt;br /&gt;
changeTime( '2011-05-15', '0', '2', '-1' ) returns 2011-02-14&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note : This function exists only on OF version 3.0 and above.&lt;br /&gt;
&lt;br /&gt;
==convertTimezone(%SOME_DATE, %SOME_TZ1, %SOME_TZ2)==&lt;br /&gt;
return %SOME_DATE converted from %SOME_TZ1 to %SOME_TZ2&lt;br /&gt;
&lt;br /&gt;
If a timezone is not valid, UTC will be used as default. For timezone list, [[allowed_timezone|see here]].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;subTime(%NOW_DATE, 'UTC', 'Europe/Paris') returns the current date converted from Greenwich (UTC) to France timezone&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : This function exists only on OF version 3.0 and above.&lt;br /&gt;
&lt;br /&gt;
==formatDate('pattern',%SOME_DATE)==&lt;br /&gt;
return the formatted %SOME_DATE. See [[CommonFormula#Date_and_time_format|Date and time format]] for more details about pattern.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;formatDate('yyyy',%START_DATE) returns the year&lt;br /&gt;
formatDate('MM', %NOW_DATE) return the month&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example available from OpenFlyers 3.0+:&lt;br /&gt;
&amp;lt;pre&amp;gt;formatDate('e',%START_DATE) returns the dow (=day of the week)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getAccount(a,b)==&lt;br /&gt;
return the account identification for the account Type a of Pilot b &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
getAccount(1,25)     return 75&lt;br /&gt;
getAccount(1,%PILOT) return 112&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getBalance(U,option B)==&lt;br /&gt;
return the balance of the user U &lt;br /&gt;
[option] account type B. &lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getBalance(1)          return -125.00&lt;br /&gt;
&lt;br /&gt;
Flight hours pricing:&lt;br /&gt;
getBalance(%PILOT)     return   25.51&lt;br /&gt;
getBalance(%PILOT,1)   return   10.00&lt;br /&gt;
getBalance(%PILOT,2)   return   10.50&lt;br /&gt;
getBalance(%PILOT,3)   return   5.01&lt;br /&gt;
&lt;br /&gt;
Product sales:&lt;br /&gt;
getBalance(%USER_ID)   return   25.51&lt;br /&gt;
getBalance(%USER_ID,1)   return   10.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getBirthdate('person id')==&lt;br /&gt;
&lt;br /&gt;
Return the birthdate of a person. Return 1900-01-01 when birthdate is not retrievable for the person.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getBirthdate(1) return 1975-01-05&lt;br /&gt;
getBirthdate(0) return 1900-01-01&lt;br /&gt;
getBirthdate(%PILOT) return 1975-01-05&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : This function exists only on OF version 3.0 and above. &lt;br /&gt;
&lt;br /&gt;
==getDebit(a)==&lt;br /&gt;
Return the sum of all debits of the account &amp;quot;a&amp;quot; made onto the current accounting period. Carry forward is not added to the sum. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;getDebit(112)   return 174.52 &lt;br /&gt;
getDebit(getAccount(1,%PILOT)) return  53.17&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getCredit(a)==&lt;br /&gt;
Return the sum of all credits of the account &amp;quot;a&amp;quot; made onto the current accounting period. Carry forward is not added to the sum.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
getCredit(14,0) return 104.12 )&lt;br /&gt;
getCredit(getAccount(1,%PILOT)) return  43.10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getFlowSumBetweenAccount('accound id 1', 'account id 2', 'start date', 'end date')==&lt;br /&gt;
return the balance difference between account 1 and account 2 from a start date to an end date&lt;br /&gt;
&amp;lt;pre&amp;gt;getFlowSumBetweenAccount(%ACCOUNT1, %ACCOUNT2, '2008-01-01', %NOW_DATE)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getSex('person id')==&lt;br /&gt;
&lt;br /&gt;
Return a number corresponding to the person sex :&lt;br /&gt;
* 0 for a man&lt;br /&gt;
* 1 for a woman&lt;br /&gt;
* 2 when it's not defined&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getSex(1)&lt;br /&gt;
getSex(%USER_ID)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example in product pricing formula to test if an user is a woman :&lt;br /&gt;
&amp;lt;pre&amp;gt;(getSex(%USER_ID) == 1) ? $womanReduction : 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getSumAccountBusinessField('business field id, 'person id', 'date')==&lt;br /&gt;
&lt;br /&gt;
Return the sum of values from a business field of &amp;quot;Account entry&amp;quot; category. Only account entries corresponding to the person and from the given date are taking into account in the calculation. Date format is YYYY-MM-DD.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getSumAccountBusinessField(13, %PILOT, formatDate( 'yyyy-01-01', %NOW_DATE ) ) ? 100 : 200&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getValidityExpiredDate('person id', 'validity type id')==&lt;br /&gt;
&lt;br /&gt;
''Note : This function exists only on OF version 3.5 and above. It's only available for flight hours pricing.''&lt;br /&gt;
&lt;br /&gt;
* Return the validity expired date of the person when the validity has a time limitation and the expired date has been set. Date format is YYYY-MM-DD&lt;br /&gt;
* Return &amp;quot;0000-00-00&amp;quot; for others cases&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getValidityExpiredDate(%PILOT, 1); // Return 2014-12-31&lt;br /&gt;
getValidityExpiredDate(0, 20); // Return 0000-00-00&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==getValue4Date(%RESOURCE_ID, 'date')==&lt;br /&gt;
&lt;br /&gt;
Return applicable variable value for the closest date.&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getValue4Date(%RESOURCE_ID, '2010-01-01 00:00:00') returns the previous and current applicable values for the booked resource id variable close to the date of 2010-01-01 00:00:00&lt;br /&gt;
getValue4Date(%RESOURCE_ID, %NOW_DATE) returns the previous and current applicable values for the booked resource id variable close to current date&lt;br /&gt;
getValue4Date(%RESOURCE_ID, %BOOKING_START_DATE) returns the previous and current applicable values for the booked resource id variable close to booking starting date&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : This function exists only on OF version 3.0 and above.&lt;br /&gt;
&lt;br /&gt;
==getYearsFromDiffDate('first date', 'second date')==&lt;br /&gt;
&lt;br /&gt;
*Return difference of year between two dates&lt;br /&gt;
*Date format is YYYY-MM-DD or YYYY-MM-DD hh:mm:ss&lt;br /&gt;
*When second date is not specified, current date is used&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;getYearsFromDiffDate( '1975-01-01', '2000-03-03') return 25&lt;br /&gt;
getYearsFromDiffDate( '1975-01-01' ) return 37&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==hasValidity('person id', 'validity type id', 'check only holding')==&lt;br /&gt;
&lt;br /&gt;
''Note : This function exists only on OF version 3 and above.''&lt;br /&gt;
&lt;br /&gt;
'check only holding' is an optional parameter. The parameter is taken into account only if its value is equal to 1. It's ignored in others cases.&lt;br /&gt;
* If 'check only holding' is different than 1 :&lt;br /&gt;
** Return '''1''' when :&lt;br /&gt;
*** If it's a validity type with experience :&lt;br /&gt;
**** the person has the required experienced&lt;br /&gt;
*** If it's not a validity type with experience :&lt;br /&gt;
**** it's a validity type without time limitation, the person has the validity&lt;br /&gt;
**** it's a validity type with time limitation, the validity of the person has not expired&lt;br /&gt;
** Return '''0''' for any others cases&lt;br /&gt;
* If 'check only holding' is equal to 1 :&lt;br /&gt;
** Return '''1''' when :&lt;br /&gt;
*** If it's not a validity type with experience :&lt;br /&gt;
**** the person has the validity&lt;br /&gt;
** Return '''0''' for any others cases (even if it's a validity type with experience and that the person has the required experience)&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;hasValidity( %PILOT, 1); // on flight hours pricing formula&lt;br /&gt;
hasValidity( %USER_ID, 20); // on sale product formula&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==min(a,b)==&lt;br /&gt;
return the minimum between a and b&lt;br /&gt;
&lt;br /&gt;
==max(a,b)==&lt;br /&gt;
return the maximum between a and b&lt;br /&gt;
&lt;br /&gt;
==roundCeil(a,b)==&lt;br /&gt;
return the a value round top to b&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;roundCeil(106,5) return 110&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to round at nearest integer 0.5 =&amp;gt; 0 (Positive value only)&lt;br /&gt;
&amp;lt;pre&amp;gt;roundCeil(107.5-0.5,1) return 107&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to round at nearest integer 0.5 =&amp;gt; 1 (Positive value with 2 decimals only)&lt;br /&gt;
&amp;lt;pre&amp;gt;roundCeil(107.5-0.499,1) return 108&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sprintf('pattern', 'string')==&lt;br /&gt;
&lt;br /&gt;
Format the string with a pattern. See [[#sprintf_format|sprintf format]] for more details about pattern.&lt;br /&gt;
&lt;br /&gt;
Example to format member num to get 5 characters and prepending zero as much as possible :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;sprintf('%05s', %MEMBER_NUM) returns 00010 if %MEMBER_NUM is 10 for exemple&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example to format member num to get 5 characters and appending zero as much as possible :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;sprintf('%-05d', %MEMBER_NUM) returns 10000 if %MEMBER_NUM is 10 for exemple&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example to format member num to get 6 characters and prepending space as much as possible :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;sprintf('%6s', %MEMBER_NUM) returns &amp;quot;    10&amp;quot; if %MEMBER_NUM is 10 for exemple&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example to format member num to a decimal with 2 digit after the decimal point :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;sprintf('%0.2f', %MEMBER_NUM) returns 10.00 if %MEMBER_NUM is 10 for exemple&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==substr(string,a,b)==&lt;br /&gt;
Return the portion of string specified by a which represents the starting point (0 being &amp;quot;from the first character&amp;quot;) and b which represents the number of character to get. When b is a negative number then that many characters will be omitted from the end of string&lt;br /&gt;
&amp;lt;pre&amp;gt;substr(%LASTNAME, 0, 5)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example :&lt;br /&gt;
&amp;lt;pre&amp;gt;substr('FIRST_NAME', 0, 5) returns FIRST&lt;br /&gt;
substr('FIRST_NAME', 0, -2) returns FIRST_NA&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==subTime(%SOME_DATE, %SOME_TZ)==&lt;br /&gt;
return %SOME_DATE with substracted time depeding of %SOME_TZ&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;subTime(%NOW_DATE, 'Europe/Paris') returns the current date converted to France timezone by substracting timezone time difference&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : This function no longer exists on OF version 3.0 and above.&lt;br /&gt;
&lt;br /&gt;
==sumFlightHour('pilot id', 'position', 'day', 'aircraft type 1' , 'aircraft type 2', 'aircraft type X')==&lt;br /&gt;
Return the flight time sum of all the flights done by a pilot in the last &amp;quot;day&amp;quot; day(s) from now and onto the &amp;quot;aircraft type 1&amp;quot;, &amp;quot;aircraft type 2&amp;quot; and &amp;quot;aircraft type X&amp;quot; (X represents another aircraft type)&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 0 to count only flight hours where pilot is assigned as first pilot.&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 1 to count only flight hours where pilot is assigned as second pilot.&lt;br /&gt;
&lt;br /&gt;
Example 1: return the flight time sum for the first pilot in the last 90 days from now and onto the aircraft type 1 and 2&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightHour(%PILOT, 0, 90, 1, 2) &lt;br /&gt;
Format sexacentimal&lt;br /&gt;
Conversion to decimal hours: Hour = Result/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example 2: return the flight time sum for the first pilot in the last 90 days onto any aircraft type&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightHour(%PILOT, 0, 90)&lt;br /&gt;
Format sexacentimal&lt;br /&gt;
Conversion to decimal hours: Hour = Result/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sumFlightTime(%PILOT, 'year', 'month', 'day', 'hour', 'minute', 'position' )==&lt;br /&gt;
return the total flight time of a pilot since a starting date. Position at 0 is first pilot, position at 1 is second pilot&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightTime(%PILOT, 2008, 01, 01, 00, 00, 0 ) returns the total flight time of first pilot since 2008-01-01 00:00:00&lt;br /&gt;
Format sexacentimal&lt;br /&gt;
Conversion to decimal hours: Hour = Result/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sumFlightTime(%PILOT, 'year', 'month', 'day', 'hour', 'minute', 'position', 'flight type' )==&lt;br /&gt;
''Note : This function exists only on OF version 3.0 and above.''&lt;br /&gt;
&lt;br /&gt;
Return the total flight time done onto the flight type of a pilot since a starting date. Position at 0 is first pilot, position at 1 is second pilot. If the flight type is not specified, the total is done onto all flight type.&lt;br /&gt;
&amp;lt;pre&amp;gt;sumFlightTime(%PILOT, 2008, 01, 01, 00, 00, 0, 64 ) returns the total flight time done onto flight type id 64 of first pilot since 2008-01-01 00:00:00&lt;br /&gt;
Format sexacentimal&lt;br /&gt;
Conversion to decimal hours: Hour = Result/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sumLandingNumber('pilot id', 'position', 'day', 'aircraft type 1' , 'aircraft type 2', 'aircraft type X')==&lt;br /&gt;
return the landing total of all the flights done by a pilot in the last &amp;quot;day&amp;quot; day(s) and onto the &amp;quot;aircraft type 1&amp;quot;, &amp;quot;aircraft type 2&amp;quot; and &amp;quot;aircraft type X&amp;quot; (X represents another aircraft type)&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 0 to count only flight hours where pilot is assigned as first pilot.&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 1 to count only flight hours where pilot is assigned as second pilot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 1 : if first pilot has done more than 5 landing in the last 30 days on aircraft type 1.&lt;br /&gt;
  sumLandingNumber(%PILOT,0,30,1) &amp;gt; 5&lt;br /&gt;
Example 2 : if second pilot has done more thant 5 landing in the last 15 days on any aircraft type.&lt;br /&gt;
  sumLandingNumber(%PILOT,1,15) &amp;gt; 5&lt;br /&gt;
&lt;br /&gt;
==sumPreviousFlightTime('pilot id', 'position', 'day', 'endingDate', 'aircraft type 1' , 'aircraft type 2', 'aircraft type X')==&lt;br /&gt;
''Note : This function exists only on OF version 3.0 and above.''&lt;br /&gt;
&lt;br /&gt;
Example: Return the flight time sum of all the flights done by a pilot, in the days &amp;quot;day&amp;quot; preceding the date time &amp;quot;endingDate&amp;quot; &lt;br /&gt;
(included) and onto the &amp;quot;aircraft type 1&amp;quot;, &amp;quot;aircraft type 2&amp;quot; and &amp;quot;aircraft type X&amp;quot; (X represents another aircraft type)&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 0 to count only flight hours where pilot is assigned as first pilot.&lt;br /&gt;
&lt;br /&gt;
Set &amp;quot;position&amp;quot; to 1 to count only flight hours where pilot is assigned as second pilot.&lt;br /&gt;
&lt;br /&gt;
Return the flight time sum for the first pilot in the 365 days preceding the date of the flight and onto the aircraft type 1 and 2&lt;br /&gt;
&amp;lt;pre&amp;gt;sumPreviousFlightTime(%PILOT, 0, 365, %START_FLIGHT, 1, 2) &lt;br /&gt;
Format sexacentimal&lt;br /&gt;
Conversion to decimal hours: Hour = Result/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==strtolower(string)==&lt;br /&gt;
Return the lower cases of string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;strtolower('CamelBack') returns &amp;quot;camelback&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==strtoupper(string)==&lt;br /&gt;
Return the upper cases of string.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;strtolower('CamelBack') returns &amp;quot;CAMELBACK&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=variables=&lt;br /&gt;
&lt;br /&gt;
==%ACCOUNT_BALANCE==&lt;br /&gt;
Account balance. Can be used in the content of the &amp;quot;Account threshold alert&amp;quot; e-mail.&lt;br /&gt;
&lt;br /&gt;
Note : This variable exists only on OF version 3.0.3 and above. &lt;br /&gt;
&lt;br /&gt;
==%ACCOUNT_TYPE==&lt;br /&gt;
account type&lt;br /&gt;
&lt;br /&gt;
==%ACCOUNT1==&lt;br /&gt;
debit account id&lt;br /&gt;
&lt;br /&gt;
==%ACCOUNT2==&lt;br /&gt;
credit account id&lt;br /&gt;
&lt;br /&gt;
==%ACCOUNTING_START_DATE==&lt;br /&gt;
accounting start date (format is YYYY-MM-DD hh:mm:ss)&lt;br /&gt;
&lt;br /&gt;
==%AIRFIELD_ARRIVAL==&lt;br /&gt;
flight airfield arrival input into the forum  (only for OF 3.0 and above)&lt;br /&gt;
&lt;br /&gt;
==%AIRFIELD_DEPARTURE==&lt;br /&gt;
flight airfield departure input into the form (only for OF 3.0 and above)&lt;br /&gt;
&lt;br /&gt;
==%AUTHENTICATION_LOGIN==&lt;br /&gt;
user login&lt;br /&gt;
&lt;br /&gt;
==%AUTO_INCREMENT==&lt;br /&gt;
auto incremental value&lt;br /&gt;
&lt;br /&gt;
==%BOOKING_START_DATE==&lt;br /&gt;
booking start date input into the form (only for OF 3.0 and above) &lt;br /&gt;
&lt;br /&gt;
==%COUNTER_ARRIVAL==&lt;br /&gt;
counter arrival input into the form&lt;br /&gt;
&lt;br /&gt;
==%COUNTER_DEPARTURE==&lt;br /&gt;
counter departure input into the form&lt;br /&gt;
&lt;br /&gt;
==%CURRENT_QUANTITY==&lt;br /&gt;
&lt;br /&gt;
The value calculated from quantity formula (only for OF 3.5 and above)&lt;br /&gt;
&lt;br /&gt;
==%CURRENT_UNIT_PRICE==&lt;br /&gt;
&lt;br /&gt;
The value calculated from unit price formula (only for OF 3.5 and above)&lt;br /&gt;
&lt;br /&gt;
==%DURATION==&lt;br /&gt;
flight time input into the form in sexacentimal&lt;br /&gt;
&lt;br /&gt;
To get value in hour :&lt;br /&gt;
&amp;lt;pre&amp;gt;%DURATION/600&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get value in minute :&lt;br /&gt;
&amp;lt;pre&amp;gt;%DURATION/10&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==%ENTITY_TZ==&lt;br /&gt;
structure/entity timezone&lt;br /&gt;
==%EXTRAFIELDxx==&lt;br /&gt;
&lt;br /&gt;
*Access to the content of an extra field&lt;br /&gt;
*xx = Id of the extra field must be add after the designation %EXTRAFIELD&lt;br /&gt;
*For pricing formula, only extra fields of type integer, float or decimal can be used&lt;br /&gt;
&lt;br /&gt;
==%FIRSTNAME==&lt;br /&gt;
user firstname&lt;br /&gt;
&lt;br /&gt;
==%LASTNAME==&lt;br /&gt;
user lastname&lt;br /&gt;
&lt;br /&gt;
==%MEMBER_NUM==&lt;br /&gt;
user member id&lt;br /&gt;
&lt;br /&gt;
==%NOW_DATE==&lt;br /&gt;
current date (format is YYYY-MM-DD hh:mm:ss)&lt;br /&gt;
&lt;br /&gt;
==%PILOT==&lt;br /&gt;
pilot id. available on flight hours pricing formula.&lt;br /&gt;
&lt;br /&gt;
==%PILOT2==&lt;br /&gt;
&lt;br /&gt;
Instructor id / Second person id. Available on flight hours pricing formula.&lt;br /&gt;
&lt;br /&gt;
This variable exists only on OF 3.5 version and above.&lt;br /&gt;
&lt;br /&gt;
==%PRODUCT_QUANTITY==&lt;br /&gt;
Quantity of purcharsed item(s)&lt;br /&gt;
&lt;br /&gt;
Note : This variable exists only on OF version 3.0.3 and above. &lt;br /&gt;
&lt;br /&gt;
==%QTY==&lt;br /&gt;
Quantity of purcharsed item(s)&lt;br /&gt;
&lt;br /&gt;
This variable exists '''only''' on OF version 3.0.&lt;br /&gt;
&lt;br /&gt;
==%RESOURCE_ID==&lt;br /&gt;
resource id (only for OF 3.0 and above)&lt;br /&gt;
&lt;br /&gt;
==%RESOURCE_NAME==&lt;br /&gt;
Resource name (only for OF 3.0 and above)&lt;br /&gt;
&lt;br /&gt;
==%START_DATE==&lt;br /&gt;
date of flight beginning (format is YYYY-MM-DD hh:mm:ss)&lt;br /&gt;
&lt;br /&gt;
==%UNIT_PRICE_VALUE==&lt;br /&gt;
Unit price for the product&lt;br /&gt;
&lt;br /&gt;
==%USER_ID==&lt;br /&gt;
user id. Available only for [[AdminDoc3#Accounting_formula|accounting formula]] and sale product formula.&lt;br /&gt;
&lt;br /&gt;
==%USER_TZ==&lt;br /&gt;
member timezone&lt;br /&gt;
&lt;br /&gt;
=Date and time format=&lt;br /&gt;
==Syntax==&lt;br /&gt;
To specify the format use a pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:&lt;br /&gt;
&lt;br /&gt;
The count of pattern letters determine the format.&lt;br /&gt;
&lt;br /&gt;
(Text): 4 or more pattern letters--use full form, &amp;lt; 4--use short or abbreviated form if one exists.&lt;br /&gt;
&lt;br /&gt;
(Number): the minimum number of digits. Shorter numbers are zero-padded to this amount. Year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.&lt;br /&gt;
&lt;br /&gt;
(Text &amp;amp; Number): 3 or over, use text, otherwise use number.&lt;br /&gt;
&lt;br /&gt;
Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.&lt;br /&gt;
&lt;br /&gt;
A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.&lt;br /&gt;
&lt;br /&gt;
===Syntax available in OpenFlyers 2.1 and above===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
!Symbol!!Meaning!!Presentation!!Example&lt;br /&gt;
|-&lt;br /&gt;
|G||era designator||Text||AD&lt;br /&gt;
|-&lt;br /&gt;
|y||year||Number||1996&lt;br /&gt;
|-&lt;br /&gt;
|M||month in year||&amp;quot;MMM&amp;quot;: Text&amp;lt;br /&amp;gt;&amp;quot;MM&amp;quot; or &amp;quot;M&amp;quot; : Number||July&amp;lt;br /&amp;gt;07 or 7&lt;br /&gt;
|-&lt;br /&gt;
|d||day in month||Number||10&lt;br /&gt;
|-&lt;br /&gt;
|h||hour in am/pm (1~12)||Number||12&lt;br /&gt;
|-&lt;br /&gt;
|H||hour in day (0~23)||Number||0&lt;br /&gt;
|-&lt;br /&gt;
|m||minute in hour||Number||30&lt;br /&gt;
|-&lt;br /&gt;
|s||second in minute||Number||55&lt;br /&gt;
|-&lt;br /&gt;
|S||millisecond||Number||978&lt;br /&gt;
|-&lt;br /&gt;
|E||day in week||Text||Tuesday&lt;br /&gt;
|-&lt;br /&gt;
|D||day in year||Number||189&lt;br /&gt;
|-&lt;br /&gt;
|F||day of week in month||Number||2 (2nd Wed in July)&lt;br /&gt;
|-&lt;br /&gt;
|w||week in year||Number||27&lt;br /&gt;
|-&lt;br /&gt;
|W||week in month||Number||2&lt;br /&gt;
|-&lt;br /&gt;
|a||am/pm marker||Text||PM&lt;br /&gt;
|-&lt;br /&gt;
|k||hour in day (1~24)||Number||24&lt;br /&gt;
|-&lt;br /&gt;
|K||hour in am/pm (0~11)||Number||0&lt;br /&gt;
|-&lt;br /&gt;
|z||time zone||Text||Pacific Standard Time&lt;br /&gt;
|-&lt;br /&gt;
|'||escape for text||Delimiter||&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;||single quote||(Literal)||'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Syntax available in OpenFlyers 3.0 and above===&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
!Symbol!!Meaning!!Presentation!!Example&lt;br /&gt;
|-&lt;br /&gt;
|e||dow (=day of week: 1 = sunday, 2 = monday, )||(Number)||2 (=monday)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Examples Using the local unit system==&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
!Format Pattern!!Result&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;yyyy.MM.dd G 'at' HH:mm:ss z&amp;quot;&amp;lt;/nowiki&amp;gt;||1996.07.10 AD at 15:08:56 PDT&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;EEE, MMM d, 'yy&amp;quot;&amp;lt;/nowiki&amp;gt;||Wed, July 10, '96&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;KK:mm a, z&amp;quot;&amp;lt;/nowiki&amp;gt;||00:08 AM, PST&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;h:mm a&amp;quot;&amp;lt;/nowiki&amp;gt;||12:08 PM&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;h 'o''clock' a, zzzz&amp;quot;&amp;lt;/nowiki&amp;gt;||12 o'clock PM, Pacific Daylight Time&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;yyyyy.MMMMM.dd GGG h:mm aaa&amp;quot;&amp;lt;/nowiki&amp;gt;||1996.July.10 AD 0:08 PM&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;nowiki&amp;gt;&amp;quot;dd/MMM/yyyyy HH:mm&amp;quot;&amp;lt;/nowiki&amp;gt;||10/07/1996 00:08&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=sprintf format=&lt;br /&gt;
&lt;br /&gt;
Pattern is made with one or more of these elements, in order:&lt;br /&gt;
* The character &amp;quot;%&amp;quot;&lt;br /&gt;
* An optional character which will be used to pad the string to the right string size. Space is used by default&lt;br /&gt;
* The character &amp;quot;-&amp;quot; for a right padding or no character for a left padding&lt;br /&gt;
* An optional number to specify how many character in minimum the string should have in final&lt;br /&gt;
* The optional character &amp;quot;.&amp;quot; followed by a digit that says how many decimal digits should be displayed for decimal&lt;br /&gt;
* One of some of these characters:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Character!!Description&lt;br /&gt;
|-&lt;br /&gt;
|d||String is treated as an integer&lt;br /&gt;
|-&lt;br /&gt;
|f||String is treated as a decimal&lt;br /&gt;
|-&lt;br /&gt;
|s||String is treated as a string&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
See [http://php.net/manual/en/function.sprintf.php sprintf definition] for the complete description.&lt;/div&gt;</summary>
		<author><name>imported&gt;Claratte</name></author>
	</entry>
</feed>