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:

This is a JavaScript function. Quotes are not needed in the rule variable name.

Tip:

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

Syntax

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

Parameters

date1

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

isPartial1

Indicates if the date1 variable is partial or not (true/false).

date2

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

isPartial2

Indicates if the date2 variable is partial or not (true/false).

operation

The operation you want to use to compare date1 and date2. For example, ">", ">=", "<", "<=", "===", or "!==".

Return value

Returns true or false.

Example 3-39 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-40 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, '===');