How to compare Dates using the Webstudio Rule Template?

How to compare Dates using the Webstudio Rule Template?

book

Article ID: KB0093092

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Description:
How to compare Dates, one date with another date - 3 days using WebStudio Rule Templates. An example has been provided below. This also makes use of the DateTime.after() and DateTime.before() functions and returns a Boolean.
Symptoms:
N/A
Cause:
N/A

Issue/Introduction

How to compare Dates using the Webstudio Rule Template?

Resolution

This sample code snippet demonstrates usage of Dates in comparison and compare Dates with -3 days ago.

DateTime.addDay(DateTime.now(),-3)
 
So you can use in a comparison:

Asset_purchase_date < DateTime.addDay(DateTime.now(),-3)
 

To check if the date is after or before the input date use: Function: DateTime.after (DateTime d1, DateTime d2)
 
d1 is a DateTime (date/time) value that will be compared with the second argument.
d2 is a  DateTime (date/time) that will be compared with the first argument.
Returns: boolean true if d1 comes after d2, otherwise return false.
 

Function: DateTime.before (DateTime d1, DateTime d2)
 
d1 is a DateTime (date/time) that will be compared with the second argument.
d2 is a DateTime (date/time) that will be compared with the first argument.
Returns: boolean true if d1 comes before d2, otherwise return false.