Time Functions

Provides deterministic, time-centric utility functions for AiSQL. Functions operate on explicit time values or on the AiSQL evaluation-time context. Note: Use of time-based functions introduces temporal variability into evaluation and should be considered when deterministic repeatability across evaluations is required.

NameParametersReturnsDescription
Time.AddDays(decimal days)DateTimeAdds days to the current time.
Time.AddDaysFrom(DateTime value, decimal days)DateTimeAdds the specified number of days to a DateTime.
Time.AddHours(decimal hours)DateTimeAdds hours to the current time.
Time.AddHoursFrom(DateTime value, decimal hours)DateTimeAdds the specified number of hours to a DateTime.
Time.AddMilliseconds(decimal milliseconds)DateTimeAdds milliseconds to the current time.
Time.AddMillisecondsFrom(DateTime value, decimal milliseconds)DateTimeAdds the specified number of milliseconds to a DateTime.
Time.AddMinutes(decimal minutes)DateTimeAdds minutes to the current time.
Time.AddMinutesFrom(DateTime value, decimal minutes)DateTimeAdds the specified number of minutes to a DateTime.
Time.AddSeconds(decimal seconds)DateTimeAdds seconds to the current time.
Time.AddSecondsFrom(DateTime value, decimal seconds)DateTimeAdds the specified number of seconds to a DateTime.
Time.AddYears(int Years)DateTimeAdds the specified number of Years from a DateTime.
Time.AddYearsFrom(DateTime value, int Years)DateTimeAdds the specified number of Years from a DateTime.
Time.DayOfWeek()intReturns the current day of week as an integer (0 = Sunday).
Time.Hour()intReturns the current hour (0–23).
Time.HoursSince(DateTime value)doubleReturns the number of hours elapsed since the given DateTime.
Time.IsAfter(DateTime value)boolReturns true if the current time is after the specified DateTime.
Time.IsBefore(DateTime value)boolReturns true if the current time is before the specified DateTime.
Time.Minute()intReturns the current minute (0–59).
Time.MinutesSince(DateTime value)doubleReturns the number of minutes elapsed since the given DateTime.
Time.Now()DateTimeReturns the current local date and time with full precision.
Time.NowHours()DateTimeReturns the current local time truncated to hours.
Time.NowMinutes()DateTimeReturns the current local time truncated to minutes.
Time.NowSeconds()DateTimeReturns the current local time truncated to seconds.
Time.Second()intReturns the current second (0–59).
Time.SecondsSince(DateTime value)doubleReturns the number of seconds elapsed since the given DateTime.
Time.SubtractDays(decimal days)DateTimeSubtracts days from the current time.
Time.SubtractDaysFrom(DateTime value, decimal days)DateTimeSubtracts the specified number of days from a DateTime.
Time.SubtractHours(decimal hours)DateTimeSubtracts hours from the current time.
Time.SubtractHoursFrom(DateTime value, decimal hours)DateTimeSubtracts the specified number of hours from a DateTime.
Time.SubtractMilliseconds(decimal milliseconds)DateTimeSubtracts milliseconds from the current time.
Time.SubtractMillisecondsFrom(DateTime value, decimal milliseconds)DateTimeSubtracts the specified number of milliseconds from a DateTime.
Time.SubtractMinutes(decimal minutes)DateTimeSubtracts minutes from the current time.
Time.SubtractMinutesFrom(DateTime value, decimal minutes)DateTimeSubtracts the specified number of minutes from a DateTime.
Time.SubtractSeconds(decimal seconds)DateTimeSubtracts seconds from the current time.
Time.SubtractSecondsFrom(DateTime value, decimal seconds)DateTimeSubtracts the specified number of seconds from a DateTime.
Time.SubtractYears(int Years)DateTimeSubtracts the specified number of Years from a DateTime.
Time.SubtractYearsFrom(DateTime value, int Years)DateTimeSubtracts the specified number of Years from a DateTime.
Time.Today()DateTimeReturns today's date with time set to 00:00:00.
Time.UtcNow()DateTimeReturns the current UTC date and time with full precision.

Examples

	
RULE TradeLatency
    IF
        TIME_DIFF_SECONDS(OrderTime, FillTime) > 2.5
        AND
        TIME_HOUR(FillTime) >= 9
    THEN
        ACTION = 'ReduceOrderRate'