getDatesCompareResult( )

Compare two dates using a provided operation. This function handles partial dates.

As far as this function may contain partial date components, dates are compared up to the first defined part for both dates (second/minute/hour/day/month/year). For example, if the following two dates are compared:
  • 01-Jun-2011 11:12:14
  • 02-Jan-2011 17:UNK:UNK
The first defined part is hour, so dates will be compared as:
  • 01-Jun-2011 11
  • 02-Jan-2011 17

Note:

The order in which parameters are supplied for date helper functions is important; the resulting return value depends on which date you pass in as the first or second parameter. The comparison will always be in the format <date1> <operation> <date2>.

Syntax

getDatesCompareResult(date1,isPartial1,date2,isPartial2,operation)

Parameters

Note:

This is a JavaScript function. Quotes are not needed in the rule variable name.
Parameter Required/Optional Description
date1 Required First rule variable of date or date/time type to be compared.

Supports Date, Datetime and Time type variables, either full or with partial components.

isPartial1 Required Boolean value (true or false) to indicate if date1 is partial or not.
date2 Required Second rule variable of date or date/time type to be compared.

Supports Date, Datetime and Time type variables, either full or with partial components.

isPartial2 Required Boolean value (true or false) to indicate if date2 is partial or not.
operation Required
The operation you want to use to compare date1 and date2. For example:
  • ">"
  • ">="
  • "<"
  • "<="
  • "==="
  • "!=="

Return value

Boolean (true or false) value as a result of the given comparison operation.

Usage tips

  • Since this function compares values, your rule expression may need to include a check to ensure the variables being passed are not null.

Examples

Example 3-40 Check if date1 is greater than date2

// check if date 1 is greater than date 2
return getDatesCompareResult(date1,true,date2,false,">");
 
 
// returns true or false

Example 3-41 Compare time part of time and datetime variables using time components only

//compare time part of time (time1) and datetime (datetime1) components
var cdate1 = new C1Date (null, null, null, null, time1.getHour(), time1.getMinute(), time1.getSecond());
var cdate2 = new C1Date (null, null, null, null, datetime1.getHour(), datetime1.getMinute(), datetime1.getSecond());
return getDatesCompareResult(cdate1, true, cdate2, true, '===');