🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators inDateRange
This page was created by Lars.olofsson on 2021-05-19. Last edited by Wikiadmin on 2026-07-29.

You use inDateRange in OCL to test whether a date is within a specified date range and return a Boolean result.

Syntax

dateToTest.inDateRange(startDate, endDate)
Part Description
dateToTest The date you want to evaluate.
startDate The first date in the range.
endDate The last date in the range.
Result A Boolean value: true when the date is in the range; otherwise false.

Example: test an acceptance period

Use the operator when a model object has an acceptance start date and end date:

DateTime.Today.inDateRange(self.AcceptFrom, self.AcceptUntil)

This expression tests whether today's date is within the period defined by AcceptFrom and AcceptUntil. For example, if DateTime.Today is January 8, 2026 and that date falls within the values in AcceptFrom and AcceptUntil, the expression returns true.

Use the Boolean result

Because inDateRange returns a Boolean value, you can use it wherever an OCL condition is required. See Documentation:OCL Boolean Operators for combining Boolean expressions.

Considerations

  • Supply the date to test first, followed by the start date and end date.
  • Confirm the behavior required by your model when the tested date is exactly the start or end date.
  • Confirm how your application should handle empty date values before using the expression in a condition.

See also