Kalenderperioden vergleichen

Kalenderperioden basieren auf Zeiteinheiten wie Jahren, Monaten, Wochen, Tagen und der Uhrzeit. Sie können beispielsweise überprüfen, ob zwei Zeitpunkte in derselben Kalenderperiode liegen oder ob ein Ereignis an einem bestimmten Wochentag bzw. zu einer bestimmten Uhrzeit stattfindet.

Verwenden Sie die folgenden Operatoren, um die Kalenderperioden zweier Zeitpunkt zu vergleichen:

  • is in the same calendar year as

    Für Monat, Woche und Tag sind ähnliche Operatoren verfügbar.

    Beispiel: the departure time of 'the flight' is in the same calendar month as the start of 'the business trip'

  • is in the same hour as

    Für Minuten und Sekunden sind ähnliche Operatoren verfügbar.

  • is before oder is after

    Beispiel: the calendar year of the departure time of 'the flight' is after the calendar year of the start of 'the business trip'.

  • is during

    Beispiel: the scheduled departure time of 'the flight' is during the calendar year 2013.

  • is during the same time as

    Dieser Operator prüft, ob zwei Zeiträume zur selben Zeit starten und enden. Beispiel: the calendar year of the scheduled departure time of 'the flight' is during the same time as the calendar year 2013.

Die folgende Regel prüft, ob der Flughafen an demselben Tag geschlossen ist, an dem der Abflug stattfindet. Wenn der Abflug am 11. Februar 2014 stattfindet, prüft die Regel, ob das Ereignis bezüglich der Schließung des Flughafens ebenfalls am 11. Februar 2014 stattfindet.

when an airport closed event occurs
definitions
    set 'the flight' to a flight in the flights of 'the airport';
if 
    this airport closed event is on the same calendar day as the scheduled departure time of 'the flight' 
then
    print "The departure airport is closed on the day of the flight.";

Die folgende Regel legt fest, dass die täglichen Ausgaben während der Reisetage den angegebenen Betrag überschreiten. Käufe am ersten und letzten Tag der Reise werden nicht berücksichtigt:

definitions
  set 'the trip' to a trip in the trips of 'the customer'; 
  set 'on-trip purchases' to all purchase events where
    the calendar day of each purchase event is after the start of 'the trip' 
      and
    the calendar day of each purchase event is before the end of 'the trip';
if the total amount of 'on-trip purchases'/ 
   the duration between the start of 'the trip' and the end of 'the trip' in days    
   is more than 1000
then print "Average spending per day is high";

Wochentag

Im Folgenden werden Einkäufe am Wochenende und während der Arbeitswoche verglichen:
definitions
    set 'purchases last 6 months' to all purchase events
        where each purchase event is during the last period of 6 months;
    set 'workweek purchases' to all purchase events in 'purchases last 6 months'
        where the day of week of each purchase event is after or the same as Monday
        and the day of week of each purchase event is before or the same as Friday;
    set 'weekend purchases' to all purchase events in 'purchases last 6 months'
        where the day of week of each purchase event is before Monday
        and the day of week of each purchase event is after Friday;
if 
    the total amount of 'weekend purchases' is more than the total amount of 'workweek purchases'
then
    print "Spending is higher at weekends.";

Die folgende Regel gewährt Rabatte für Käufe an Bord, die an einem Dienstag getätigt werden:

definitions
    set 'the flight' to a flight in the flights of 'the customer';
    set 'the flight period' to the period between the scheduled departure time of 'the flight' and the scheduled arrival time of 'the flight';
    set 'purchase on board' to a purchase event
        where this purchase event is during 'the flight period';
if 
    'purchase on board' is on Tuesday
then
    print "apply special Tuesday discount for on-board purchases.";

Uhrzeit

Eine Uhrzeit wird in Stunden, Minuten und Sekunden in einer gängigen Zeitschreibweise angegeben, z. B. 11:59:59 PM.

Die folgende Regel vergleicht die Anzahl der Flüge am Morgen mit der Anzahl der Flüge am Nachmittag während der letzten sechs Monate:

definitions
    set 'flights last six months' to all flights in the flights of 'the customer'
        where the scheduled departure time of each flight is during the last period of 6 months;
    set 'morning flights' to all flights in 'flights last six months'
        where the time of day of the scheduled departure time of each flight is before 12:00:00 PM;
    set 'afternoon flights' to all flights in 'flights last six months'
        where the time of day of the scheduled departure time of each flight is after or the same as 12:00:00 PM;
if 
    the number of flights in 'morning flights' is more than the number of flights in 'afternoon flights'
then
    print "more morning flights than afternoon flights.";