Typical formula
Presentation
This page gathers some examples of formula with theirs explanations.
Allowed Comparison operators are : equal (=), greater than (>), lesser than (<)
Apply another pricing after a period time
The pricing rule is as followed : If a flight starts after 7:00 am UTC (7:00 am included), we apply a pricing of $1. Otherwise, we apply a pricing of $2.
The formula will be :
( (formatDate('hmm',%START_DATE) > 659) ? $1 : $2 )
- %START_DATE is an internal variable representing the flight start date. The date is in UTC timezone
- formatDate is an internal function to format a date into another format
- formatDate('hmm',%START_DATE) will format the date by using the pattern hmm
- It gives 1511 for the date 2011-01-05 15:11:01
- It gives 700 for the date 2011-01-12 07:00:00
- (formatDate('hmm',%START_DATE) > 659) is the rule condition we want to apply
- 659 represents 6:59 am
- 659 is used instead of 700 because 7:00 am is included.
- When comparing a time with this pattern 'hmm', the time range is 0 - 2359
The pricing rule is as followed : All flights are always done into France. If a flight starts after 11:00 am (11:00 am included), we apply a pricing of $1. Otherwise, we apply a pricing of $2.
The formula will be :
( (formatDate( 'hmm',convertTimezone(%START_DATE, 'UTC','Europe/Paris') ) > 1100) ? $1 : $2 )
- convertTimezone is an internal function to convert a date from a timezone to another timezone
- since %START_DATE is already in UTC, we let the timezone UTC as second parameter of the function
- Europe/Paris is the timezone used in France
- Formula is regardless of daylight saving time