Dates

Using Dates in Conditions

samples/basic/tutorial/shopping.kb

KnowledgeWright supports a wide variety of date calculations that can be used in conditions in rule_sets and rules_tables.

The full set of date capabilities are described under Expressions.

As an example, we'll create a knowledgebase that helps plan your shopping activities for Christmas.

  1. Create a fill_in_the_blank question named christmas that asks for the Christmas date to plan for. Make sure you set answer_type to date. Also set the date_format to whatever form you want your user to enter the date in.
  2. Create a rule_set named action with the following table:
    conditions
    value
    today >= christmas
    "Too late; find new friends. 
    Your family might forgive you."
    today = christmas
    "Too late for shopping; 
    bake cookies quick."
    tomorrow = christmas
    "Go shopping at the mall right 
    this minute."
    christmas - 1 weeks < today
    
    "Either order today from the 
    Internet with overnight shipping
    (hope you've got alot of money)
    or go shopping as soon as possible
    at the mall (hope you like crowds)."
    christmas - 1 months < today
    "Order all your presents on the 
    Internet."
    true
    "Take your time and shop on the 
    Internet."

    Notice the last row the conditions are true, so if none of the other rows match, this one will.

  3. In knowledgebase main, set the goals to action. Note that you can select action from the pull-down menu rather than typing it in.
  4. Run the knowledgebase. If it's not near Christmas, try making Christmas 2 days from today, or a week and a half from today.

Copyright ©1996-2002 Amzi! inc. All Rights Reserved. Amzi!, KnowledgeWright and WebLS are registered trademarks and Subscription Plus and Logic Server are trademarks of Amzi! inc.