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 (
trueorfalse).
Syntax
self.[DateTimeProperty].TimeOfDay.inTimeRange(TimeSpan.FromHours(X), TimeSpan.FromHours(Y))
TimeOfDay: Extracts the duration since midnight from theDateTime.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:
- Value Extraction (
.TimeOfDay):- This converts the full
DateTime(e.g.,2026-03-09 14:30) into aTimeSpan(e.g.,14:30:00). - This ensures the comparison is day-independent.
- This converts the full
- 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).
- Variable Assignment (
vResult := ...):- The result is a Boolean (
TrueorFalse). - The
:=operator assigns this result to a variable for use in subsequent logic or UI display.
- The result is a Boolean (
