Introduction to RASON
About RASON Models and the RASON Server
Rason Subscriptions
Rason Web IDE
Creating and Running a Decision Flow
Defining Your Optimization Model
Defining Your Simulation Model
Performing Sensitivity Analysis
Defining Your Stochastic Optimization Model
Defining Your Data Science Model
Defining Custom Types
Defining Custom Functions
Defining Your Decision Table
Defining Contexts
Using the REST API
REST API Quick Call Endpoints
REST API Endpoints
Decision Flow REST API Endpoints
OData Endpoints
OData Service for Decision Flows
Creating Your Own Application
Using Arrays, For, Loops and Tables
Organization Accounts

Decision Tables with Dates and Times

This section presents a special class of tables, in which the specific Date, Time and Duration data types are utilized. Open the example, DT Date & Time examples.json on the Editor page on RASON.com to display the following example RASON code. For a list of supported operators, see the Decision Tables section within the RASON Reference Guide.

This example model invokes three decision tables: tblRiskRating, tblTollTax and tblParkingFee. In the first decision table, tblRiskRating, a decision table is created to determine the medical risk of an individual given their age and medical history. The second decision table, tblTollTax, determines the rate of traffic and the toll, given the time entering the toll road and the third decision table, tblParkingFee, determines a parking fee based on the time spent in the parking facility. Let's take a closer look at all three.


{
 "modelName": "DTDateTimeExample",
 "modelDescription": "Date and Time Decision Table Examples",
 "modelType": "calculation",
 "decisionTables": {
    "tblRiskRating": {
      "inputs": [ "birthDate", "medHistory" ],
      "outputs": [ "riskRating" ],
      "refTypes": [ "date", "text", "text" ],
      "rules": [ 
        [ ">'1970-05-05'", "good", "medium" ],
        [ ">'1970-05-05'", "bad",  "high" ],
        [ "['1935-05-05'..'1970-05-05']", "-", "medium" ],
        [ "<'1935-05-05'", "good", "low" ],
  [ "<'1935-05-05'",  "bad", "medium" ]
],
"hitPolicy": "U"
    },
    "tblTollTax": {
      "inputs": [ "operTime" ],
      "outputs": [ "traffic", "toll" ],
      "refTypes": [ "time", "text", "number" ],
      "rules": [
        [ ">'19:00:00'", "low", 5 ],
        [ "['15:00:00'..'19:00:00']", "high", 7 ],
        [ "['09:00:00'..'15:00:00')", "medium", 6 ],
        [ "['06:00:00'..'09:00:00')", "high", 7 ],
        [ "<'06:00:00'", "low", 5 ]
      ],
      "hitPolicy": "U"
    },
    "tblParkingFee": {
      "inputs": [ "dtDuration" ],
      "outputs": [ "parkingFee" ],
      "refTypes": [ "duration", "number" ],
      "rules": [
        [ "<'PT20M'", 0 ],
        [ "['PT20M'..'PT1H')",
          "2 *ceiling(duration(dtDuration)/duration('PT20M'))"
        ],
        [ "['PT1H'..'PT4H')", 
          "6 *ceiling(duration(dtDuration)/duration('PT1H'))"
        ],
        [
          ">='PT4H'",
          "30*ceiling(duration(dtDuration)/duration('P1D'))"
        ]
      ],
      "hitPolicy": "U"
    }
  },
  "data": {
    "Date1": {
      "value": "'1964-05-05'",
      "comment": "bd"
    },
    "Date2": {
      "value": "good",
      "comment": "mh"
    },
    "actualTimeEntered": {
      "value": "'18:50:05'",
      "comment": "bynow"
    },
    "durationParked": {
      "value": "PT25M",
      "comment": "period"
    }
  },
  "formulas": {
    "dateResult": {
      "formula": "tblRiskRating(,,Date1, Date2)",
      "finalValue": []
    },
    "tollResult": {
      "formula": "tblTollTax('toll',,actualTimeEntered)",
      "finalValue": []
    },
    "trafficResult": {
      "formula": "tblTollTax('traffic',,actualTimeEntered)",
      "finalValue": []
    },
        "durationResult": {
            "formula": "tblParkingFee(,,durationParked)",
            "finalValue": []
        }
    }
} 
Back to Decision Table Hit Policy: Unique