_CompareDates

Compares two date times to determine whether the first date time is less than, equal to, or greater than the second date time.

Syntax

_CompareDates(date1,date2)

Parameters

Parameter Definition Data type

date1

First date to use.

PFDateTime

date2

Second date to use.

PFDateTime

Returns

One of the following (Integer):

  • -1—If date1 is less than date2.
  • 0—If date1 equals date2.
  • 1—If date1 is greater than date2.

Notes

Both dates are normalized before comparison. For more information, see Date time processing.

Example

This example of a constraint rule uses both the GetSiteTime and _CompareDates functions to check whether the date entered is in the future. It is attached at the item level to a DOV item.

evaluate on Form Submission
    value = _CompareDates(this.Value, GetSiteTime())
when value == 1
    issue query: Date cannot be in the future compared to System Date

You could also write the rule to evaluate to true or false instead of to a numeric value:

evaluate on Form Submission
    value = _CompareDates(this.Value, GetSiteTime()) == 1
when value is true
    issue query: Date cannot be in the future compared to System Date