Time point operators

Use time point operators to specify an event, calculate a time period, and compare time points.

A time point is an instant of time that is measured in a time scale. A time point is characterized by a time instant and a time zone. Two time points are equal if they represent the same time instant in the same time zone.

In Decision Server Insights, time points are measured in the time scales that are defined for a given time zone.

The following tables list the operators that you can use to define and compare time points. The placeholder <a date> represents a time point, which can be an event, a time, or an attribute of type date or time.

For more information about time points, see Reasoning over time and events.

Table 1. Operators for comparing time points
Operator Example Comments

<a date> is at the same time as <a date>

'the scheduled departure' is at the same time as the start of 'the flight period' 

Tests that a time point is at the same time instant as another time point, independently of their time zones.

<a date> is in the same calendar year as <a date>

the scheduled departure of 'this flight' is in the same calendar year as the start of 'this trip period'
 

<a date> is in the same calendar month as <a date>

 the scheduled departure of 'this flight' is in the same calendar month as the start of 'this trip period'
 

<a date> is in the same calendar week as <a date>

the scheduled departure of 'this flight' is in the same calendar week as the start of 'this trip period'

A calendar week starts on the Monday and ends on the Sunday.

<a date> is on the same calendar day as <a date>

the scheduled departure of 'this flight' is on the same calendar day as the start of 'this trip period'
 

<a date> is in the same hour as <a date>

the scheduled departure of 'this flight' is in the same hour as the start of 'this trip period'
 

<a date> is in the same minute as <a date>

the scheduled departure of 'this flight' is in the same minute as the start of 'this trip period'
 

<a date> is in the same second as <a date>

the scheduled departure of 'this flight' is in the same second as the start of 'this trip period'
 

<a date> is after <a date>

the return date of 'rented car' is after 05/07/2007 05:00:00 PM

Tests that a date comes after another date.

<a date> is after <a date> and on or before <a date>

the return date of 'rented car' is after 'pickup date' and on or before 'scheduled return date'

Tests that date A is after date B, and that date A is before or the same as date C.

<a date> is after <a date> and before <a date>

the return date of 'rented car' is after 'pickup date' and before 'scheduled return date'

Tests that date A is after date B, and that date A is before date C.

<a date> is after or the same as <a date>

the return date of 'rented car' is after or the same as 05/07/2007 05:00:00 PM

Tests that a date comes after another date, or is the same as that other date.

<a date> is before <a date>

the return date of 'rented car' is before 05/07/2007 05:00:00 PM

Tests that a date comes before another date.

<a date> is before or the same as <a date>

the return date of 'rented car' is before or the same as 05/07/2007 05:00:00 PM

Tests that a date comes before another date, or is the same as that other date.

<a date> is on <simple date>

the return date of 'rented car' is on 05/07/2007

Tests that a date is on a specific date that is specified without a time.

<a date> is on or after <a date> and before <a date>

the return date of 'rented car' is on or after 'pickup date' and before 'scheduled return date'

Tests that date A is the same as or after date B, and that date A is before date C.

<a date> is on or after <a date> and on or before <a date>

the return date of 'rented car' is on or after 'pickup date' and on or before 'scheduled return date'

Tests that date A is the same as or after date B, and that date A is the same as or before date C.

Table 2. Operators for comparing a time point and a time period
Operator Example Comment

<a date> is after <a time period>

'the purchase event' is after 'the flight period' 

Tests that a time point is at the same instant as the end of the period or later.

<a date> is before <a time period>

the departure time of 'the flight' is before the calendar month February 2013 

Tests that a time point is earlier or at the same instant as the start of the period.

<a date> is during <a time period>

'the purchase event' is during the period of 2 hours after the start of 'the business trip' 

Tests if a time point is later or at the same instant as the start time of the period, and earlier or at the same instant as the end time of the period.

<a date> is within <a calendar duration> before <a date>

'this ticket checkin event' is within 2 hours before the scheduled departure of 'this flight',
 

<a date> is within <a calendar duration> after <a date>

'this ticket checkin event' is within 20 minutes after the scheduled departure of 'this flight',
 

<a date> is within <an absolute duration> before <a date>

'this purchase event' is within the duration of 'the wait time' before the scheduled departure of 'this flight',
 

<a date> is within <an absolute duration> after <a date>

'this purchase event' is within the duration of 'the flight' after the scheduled departure of 'this flight',
 
Table 3. Operators for testing that a component of the representation of a time point has a specific value
Operator Example Comment

<a date> is on day <a number>

the scheduled departure of 'this flight' is on day 17,
 

<a date> is in hour <a number>

the scheduled departure of 'this flight' is in hour 14,
 

<a date> is in minute <a number>

the scheduled departure of 'this flight' is in minute 30,
 

<a date> is in second <a number>

the scheduled departure of 'this flight' is in second 15,
 

<a date> is in <month>

the return date of 'rented car' is in October

Tests that a date is in a specific month.

<a date> is in <month> <year>

the return date of 'rented car' is in October 2007

Tests that a date is in the specified month of the specified year.

<a date> is in year <year>

the return date of 'rented car' is in year 2007

Tests that a date is in the specified year.

<a date> is on <a day of week>

the return date of 'rented car' is on Thursday

Tests that a date is on a specific day of the week.

<a date> is on <day of week> at <time>

the return date of 'rented car' is on Thursday at 05:00:00 PM

Tests that a date is on a specific day of the week, at a specific time.

<a date> is at <time>

the return date of 'rented car' is at 05:00:00 PM

Tests that the time part of a date is at the specified time of day.

Table 4. Accessors for time points
Operator Example Comment

the year of <a date>

the year of the original departure of 'the flight' is the year 2013

Returns the number of the year, such as year 2013.

Note: This operator returns an object rather than an integer. You cannot use this operator in arithmetic operations such as equals <number>, but you can use it in comparison operations, such as is, is one of, is after. For example,
the year of 'the check-in event' is the year 2013

the month of year of <a date>

the month of year of the scheduled departure of 'the flight' is February 

Returns the name of the month, ranging from January to December.

the day of month of <a date>

the day of month of  the scheduled departure of 'the flight' is the day of month 14

Returns the number of the day in the month, ranging from the day of month 1 to the day of month 31.

Note: This operator returns an object rather than an integer. You cannot use this operator in arithmetic operations such as equals <number>, but you can use it in comparison operations, such as is, is one of, is after. For example,
the day of month of 'the check-in event' is the day of month 13

the hour of day of <a date>

the hour of day of the scheduled departure of 'the flight' is the hour of day of the original departure of 'the flight'   

Returns the hour in the day, ranging from the hour 0 to the hour 24.

Note: This operator returns an object rather than an integer. You cannot use this operator in arithmetic operations such as equals <number>, but you can use it in comparison operations, such as is, is one of, is after. For example,
the hour of day of 'the check-in event' is the hour of day 16

the minute of hour of <a date>

the minute of hour of the scheduled departure of 'the flight' is between the minute of hour 15 and the minute of hour 30  

Returns the minute in the hour, ranging from the minute 0 to the minute 59.

Note: This operator returns an object rather than an integer. You cannot use this operator in arithmetic operations such as equals <number>, but you can use it in comparison operations, such as is, is one of, is after. For example,
the minute of hour of 'the check-in event' is the minute of hour 30

the second of minute of <a date>

the second of minute of the scheduled departure of 'the flight' is the second of minute 10  

Returns the second in the minute, ranging from the second 0 to the second 59.

Note: This operator returns an object rather than an integer. You cannot use this operator in arithmetic operations such as equals <number>, but you can use it in comparison operations, such as is, is one of, is after. For example,
the second of minute of 'the check-in event' is the second of minute 50

the day of week of <a date>

the day of week of the scheduled departure of 'the flight' is Tuesday  

Returns the day of the week, ranging from Sunday to Saturday.

the time of day of <a date>

the time of day of the scheduled departure of 'the flight' is 2:57:06 PM   

Returns the time of the day, ranging from 00:00:00 AM to 11:59:59 PM.

the calendar year of <a date>

the calendar year of the departure time of 'the flight' 

Returns a time period.

the calendar month of <a date>

the calendar month of the departure time of 'the flight' 

Returns a time period.

the calendar week of <a date>

the calendar week of the departure time of 'the flight' 

Returns a time period. A calendar week starts on the Monday and ends on the Sunday.

the calendar day of <a date>

the calendar day of the departure time of 'the flight' 

Returns a time period.

the hour of <a date>

the hour of the departure time of 'the flight' 

Returns a time period.

the minute of <a date>

the minute of the departure time of 'the flight' 

Returns a time period.

the second of <a date>

the second of the departure time of 'the flight' 

Returns a time period.

Table 5. Conversion operators for time points
Operator Example Comment

the local time of <a date> in <string>

the local time of this meeting event in "Europe/Paris" is at 5:00 PM

Specifies the time zone for a time point. The string is the time zone ID.

Examples of time zone IDs are "Europe/Paris", "America/New_York", "Asia/Tokyo".

Note: The following methods are used to create a time zone ID and to define the list of time zone IDs available in the prediction menu: java.time.ZoneId#of(java.lang.String) and java.time.ZoneRulesProvider#getAvailableZoneIds()

the local time of <a date> in the zone of <a date>

the time of day of the local time of this purchase event in the zone of 'the flight event' is after 5:00 PM

Converts the first time point to the time zone of the second time point.

Table 6. Operators on collections of time points
Operator Example Comment

<time point collection> before <a date>

all flight delay events before the start of 'the holiday'
 

<time point collection> after <a date>

all flight delay events after the start of 'the holiday'
 

<time point collection> at <a date>

all flight delay events at the start of 'the holiday'
 

<time point collection> before or at <a date>

all flight delay events before or at the start of 'the holiday'
 

<time point collection> at or after <a date>

all flight delay events at or after the start of 'the holiday'
 

Example: the hour of day of

if
    there is at least one ticket checkin event
        where the hour of day of this checkin event is one of {the hour of day 7, the hour of day 8, the hour of day 9}
then
    print "Peak-time travel.";