Optimize 10.7 | webMethods Optimize Documentation | Using webMethods Optimize | Defining Rules | Creating Rule Expressions | Creating a Date-Time Rule Expression
 
Creating a Date-Time Rule Expression
A Date-Time rule expression compares two time-related operands for a KPI or Event rule. A Date-Time expression can be a simple expression or, more typically, it can be an element of a compound rule expression. Note that like other rule expressions, Date-Time expressions are subject to logical restrictions based on operand selections, so you should familiarize yourself with operand functionality and consider what factors you are trying to evaluate before attempting to construct an expression. Also, refer to Creating Rule Expressions in this chapter for general information about working with the rule expression editor before attempting to create a Date-Time expression.
For a Date-Time expression, the first operand can be either a KPI Value or Time value; the second operand can be values discussed in Creating Rule Expressions of this chapter as applicable for Date-Time expressions. Note that if the Date-Time expression is the main component of an expression, at least one of the operands must be a KPI value. This is not required if the Date-Time rule expression is a member of a compound rule expression (for example: a rule that fires when a KPI value represents total sales greater than $1M AND day-of-week is Monday).
While the Rule Expression editor enables you to create a standalone Date-Time expression, such an expression rarely makes sense in a real world business environment. More typically, a Date-Time expression is used as a component of a simple expression or as an embedded expression within a compound rule expression. The examples in the following section of this chapter illustrate some of these typical usage patterns.
There are five basic types of Date-Time expressions you can create that make sense in most business environments.
*Day of Week: This type of expression evaluates whether an event or KPI reading occurs before, during, or after a particular day of the week.
*Time of Day: This type of expression evaluates whether an event or KPI reading occurs before or after a particular time of the day.
*Month: This type of expression evaluates whether an event or KPI reading occurs before, during, or after a particular month.
*Simple expressions that use reading day: This somewhat special expression is a simple expression that uses a Date-Time component (reading day) to evaluate an event.
*Reading Day expression structured as a Date-Time expression.
The following table provides a reference for choosing the appropriate symbol for a Time operand when creating a Date-Time expression.
Symbol
Value
Day of Week
Current day of the week as a number, where SUNDAY = 1 and SATURDAY = 7
Month
Current month as a number where JANUARY = 1 and DECEMBER = 12
Sunday
Literal value = 1
Monday
Literal value = 2
Tuesday
Literal value = 3
Wednesday
Literal value = 4
Thursday
Literal value = 5
Friday
Literal value = 6
Saturday
Literal value = 7
Workday
Literal value can be 2, 3, 4, 5, or 6
Weekend
Literal value can be 1 or 7
January
Literal value = 1
February
Literal value = 2
March
Literal value = 3
April
Literal value = 4
May
Literal value = 5
June
Literal value = 6
July
Literal value = 7
August
Literal value = 8
September
Literal value = 9
October
Literal value = 10
November
Literal value = 11
December
Literal value = 12
The following procedure describes how to create a basic Date-Time expression. Note that when creating a Date-Time expression, you cannot really consider each operand independently; instead, you must think about logically relate to each other. For instance, if your first operand is Time, and you need to specify a value, the same value must apply to both operands. Note also that this procedure is primarily for instructional purposes; in most cases, a simple, standalone Date-Time expression will have very limited real world applicability.
The examples that follow illustrate more practical Date-Time expressions that relate to real world scenarios.
*To create a date-time rule expression
1. In the Expression list of the Rule Expression panel, click Date-Time Expression. Optimize displays the rule expression fields shown in the following figure.
Data-Time Rule Expression Fields
2. In the first Operand list, select KPI Value or Time. The available fields below the first Operand field change based on your selection as described below.
*If you select KPI Value as the first operand, you must select the appropriate category and specific name for the KPI in the Category and KPI fields that appear. Refer to Defining KPI Value as the First Operand of this chapter for more information about KPI operands. In most cases for Date-Time expressions, you will select one of the following: "Reading Day", "Reading Time", "Reading Date" or "Reading Value" (although Reading Value should represent some date/time value). The second operand selection should logically correspond with the first operand. For example, if "Reading Day" is the first operand, the second operand should be a day of the week equate to a day of the week symbol - "Reading Day" AT "WORKDAY".
*If you select Time as the first operand, you must select the appropriate unit from the Symbol field: TIME OF DAY, DAY OF WEEK or MONTH. When you select the second operand, it must logically correspond to the Time selection. For example, if the first operand is Reading Day, the second operand should be a day of the week that equates to a day of the week symbol, i.e.: “Reading Day” AT “WORKDAY”. See the table preceding this procedure for information about the various time measures you can select.
3. In the Symbol list, click the date-related or time-related measure that you want to compare to the second operand.
The following table describes the time measures.
Time Measure
Description
DAY OF WEEK
The current day of the week represented as an integer where SUNDAY = 1 and SATURDAY = 7.
TIME OF DAY
The current time represented as hours and minutes “hhmm”.
MONTH
The current month represented as an integer where JANUARY = 1 and DECEMBER = 12.
4. In the Date-Time list, click the time-related comparator to compare the two operands (Before, At, or After).
5. In the secondOperand list, select one of the following options (remember that this operand must logically correspond to the value of first operand):
*KPI Value: If you select KPI Value as the second operand, you must select the appropriate category and specific name for the KPI in the Category and KPI fields. Refer to Defining KPI Value as the First Operand of this chapter for more information about KPI operands.
*Number: In the Value text box, enter a numeric value to compare to the first operand.
*Time: Select an appropriate symbol to correspond to the first operand. Refer to the information in Creating a Simple Rule Expression and to the table preceding this procedure for information about the various time measures you can select.
*Math: Construct a mathematical operation that resolves to a number which corresponds to the value of the first operand.
Important:
Express all dates and times based on the time zone at the location of the Analytic Engine.
6. When you are finished working with your expression, click Save to save the rule expression.