🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators time
This page was created by Charles on 2024-09-21. Last edited by Wikiadmin on 2026-07-29.

You can use the time OCL operator when you need the current system time of day without its calendar date, for example when assigning or comparing a time-of-day value.

What time returns

The time operator returns the time part of the current system time, equivalent to taking the time component from DateTime.Now.

It removes the year, month, and day and retains the hour, minute, second, and millisecond. The value is evaluated when the OCL expression runs.

Syntax

time

Example

If the current system date and time is 2026-07-28 14:30:15.250, this expression:

time

returns the time-of-day value 14:30:15.250. The date 2026-07-28 is not included.

When to use it

Use time when your logic depends on the current clock time rather than the current calendar date. For example, you can use the current time of day as input to a time-range check:

time.inTimeRange(TimeSpan.FromHours(9), TimeSpan.FromHours(17))

This evaluates whether the current time is in the range from 09:00 to 17:00. See Documentation:OCLOperators inTimeRange for the range comparison rules and TimeSpan requirements.

Time and date are different values

Do not use time when you need today's date. Use date to obtain a date value with its time component set to midnight.

Need Use Example result when the system clock is 2026-07-28 14:30:15.250
Current time of day only time 14:30:15.250
Current date only date 2026-07-28 00:00:00

See also