Skip to main content

MilliSecondOfTheHour

Function MilliSecondOfTheHour(const AValue: TDateTime): LongWord

Example

procedure ScriptEvent(var Value: variant);
var
InputValue: TDateTime;
begin
InputValue := EncodeDateTime(2026, 7, 18, 9, 2, 3, 4);
Value := MilliSecondOfTheHour(InputValue); // 123004
end;

Usage

MilliSecondOfTheHour returns the zero-based millisecond index within the encoded hour.

Parameters

NameTypeDescription
AValueTDateTime, constEncoded date/time whose time-of-hour fields are inspected.

Returns

A LongWord in the inclusive range 0 through 3,599,999.

Behaviour

  • The date component does not affect the result.
  • The value resets to zero at the start of the next encoded hour.
  • Decoding is sign-aware for valid pre-epoch TDateTime values, so the returned field position remains non-negative.
  • The routine extracts encoded wall-clock fields; it does not consult or convert a timezone.

Important usage notes

  • Velox decodes to millisecond resolution. Any finer binary fraction in a manually calculated TDateTime is subject to the runtime's timestamp rounding.
  • The result is not “milliseconds elapsed since” another instant and does not account for daylight-saving gaps, repeats or leap seconds.
  • Invalid or non-finite encoded input can raise during decoding rather than returning a sentinel.
  • Use an interval routine when the requirement is a duration; component indices wrap at their documented boundary.

Errors

Velox performs no validation or exception translation. Date/time decode exceptions propagate to the script.

Additional Technical Info

MilliSecondOfTheHour returns the zero-based millisecond index within the encoded hour. It is a position within the encoded hour, not an elapsed-duration measurement between two values.

The example is fictional, deterministic and source-reviewed. It was not executed by the documentation workflow.

Implementation

The DateUtils import binds directly to Delphi 37.0 System.DateUtils.MilliSecondOfTheHour. It decodes the time fields and returns millisecond + 1,000 * (second + 60 * minute).

Side effects

None.

Performance and concurrency

Constant-time component decoding and integer arithmetic with no external I/O or shared mutable state.

Remarks

This function is suitable for sorting, bucketing or formatting by encoded hour position. Preserve the surrounding date/time fields when the value must identify an instant.

Related entries

External references

Created 2026-07-15