🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators inTimeRange
Created by Stephanie on 2025-01-08 · Last edited by Vale.buyondo on 2026-03-09.

inTimeRange is a logic operator used to determine if a specific DateTime value falls between two other points in time.

  • CLR Bound: By calling through to the Common Language Runtime (CLR), the operator ensures that time comparisons follow standard .NET rules, including handling of ticks and milliseconds.
  • Result: It always returns a Boolean (true or false).

Syntax

self.[DateTimeProperty].TimeOfDay.inTimeRange(TimeSpan.FromHours(X), TimeSpan.FromHours(Y))
  • TimeOfDay: Extracts the duration since midnight from the DateTime.
  • TimeSpan.FromHours(n): A direct call to the .NET library to create a valid duration object for the range.

Example

-- Check if the Order time falls within the defined TimeSpan range
vResult := self.OrderDate.TimeOfDay.inTimeRange(TimeSpan.FromHours(0),TimeSpan.FromHours(0))

To avoid the common "Type Mismatch" error (where DateTime is compared to TimeSpan), the implementation follows three critical steps:

  1. Value Extraction (.TimeOfDay):
    • This converts the full DateTime (e.g., 2026-03-09 14:30) into a TimeSpan (e.g., 14:30:00).
    • This ensures the comparison is day-independent.
  2. Range Definition (TimeSpan.FromHours):
    • The start and end points are defined using direct CLR calls.
    • In the example above, using (0, 0) checks for the exact start of the day (Midnight).
  3. Variable Assignment (vResult := ...):
    • The result is a Boolean (True or False).
    • The := operator assigns this result to a variable for use in subsequent logic or UI display.