Compare

The Compare component compares two date and time instances and displays if the first and the second date or time instances are the same, or if first date or time instance is before or after the second one.

Screenshot

Ports

The Compare component exposes the Control In, Control Out, Data In, and Data Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Can be connected to the Control In port of another component or the default end component.
Data In The Compare component exposes the following Data In ports:
date1 (DateTime): specifies the first date or instance to compare.
date2 (DateTime): specifies the second date or instance to compare.
Data Out Returns an integer (int32) as follows:
Returns “1”, if date1 is greater than date2
Returns “0”, if both dates values are equal
Returns “-1”, if date2 is less than date1

Example

Let us consider an example of comparing two dates.

Screenshot

To compare the dates:

  1. In the Toolbox, expand Utilities and then expand DateTime.
  2. Drag the Compare component and drop it on the Design surface.
  3. Double-click the date1 box and enter the first date to compare.
  4. Double-click the date2 box and enter the second date to compare.

    Note

    You can override the existing data source for both the data1 and data2 Data In ports. To override the existing data source:

    • Right-click the required Data In port.
    • Click Override and change the data source.
      To learn more about overriding the data source of the data port, refer the Override section.

  5. To edit the properties of the Compare component, in the Properties window, change the required property. You can edit the following properties.

    Property Description
    Search Search for the respective property.
    Delay After Execution Specifies the wait time (in seconds) after the action is performed.
    Delay Before Execution Specifies the wait time (in seconds) before the action is performed.

    To enable display of the returned value, you can add a MessageBox component to the activity.

  6. To add the MessageBox component:

    • In the Toolbox, expand General.
    • Expand the MessageBox component, drag the Show component and drop it on the Design surface.
  7. Connect the control ports and data ports in the activity.
  8. In the toolbar, click Run.
    The messagebox displays a value, based on whether the dates are the same or if the first date is before or after the second date

    Screenshot