top of page

92. Is Date X after Date Y?

Description

How to determine of a date falls after a given date.

Code

Examples:

DateVar1 > DateVar2

DateVar1 >= DateVar2

DateVar > DATE OF( 25, 12, 2000 )

DateVar > DATE OF( 25, 12, YEAR OF( TODAY ) )


Date is after Christmas of the current year:

FALSE
IF DateVar >= DATE OF( 25, 12, YEAR OF( TODAY ) )
TRUE
END IF

Explanation

You can compare two dates using the normal comparison operators, as described in Computation 11: Comparing Dates. To find if date X is after date Y, use one of these operators:

X > Y Date X is after date Y
X >= Y Date X is on or after date Y
The X and Y values must both be HotDocs date values, not just strings containing dates. In other words, both dates must be either date variables or must use the DATE OF( day, month, year ) model, as shown in the examples above.

Because the year of the date we are comparing is not always fixed, it is sometimes good to use the YEAR OF( TODAY ) model. For example, so see if a date is after Christmas of the current year, use the fourth example in the first set of examples above. This is duplicated in the "Christmas" example, which looks at DateVar and determines if it occurs on or after Christmas of the current year. If it does, the computation returns TRUE. Otherwise it returns false.

bottom of page