Skip to main content

AsDateTime

property AsDateTime: TDateTime read write;

Example

procedure ScriptEvent(var Value: Variant);
begin
Locals['RunAt'].AsDateTime := Now;
Value := Locals['RunAt'].AsDateTime;
end;

Usage

AsDateTime converts the raw Variant to TDateTime on read and stores a varDate Variant on write.

Additional Technical Info

AsDateTime reads with Delphi VarToDateTime(FValue) and writes with VarFromDateTime under the variable monitor.

Failed reads, including Null or nonconvertible text, propagate the Delphi Variant conversion exception; Velox does not catch it here. Interpretation of convertible text follows the runtime/locale conversion rules rather than a Velox format string.

The setter stores a varDate Variant directly. It bypasses Value validation and encryption. Both directions use raw FValue, so this alias is unsuitable for an encrypted variable whose normal stored representation is ciphertext.

Official references: Delphi VarToDateTime, Free Pascal VarToDateTime, Delphi VarFromDateTime, Free Pascal VarFromDateTime. Free Pascal is a compatibility reference; current Delphi behaviour is authoritative for Velox.

Created 2026-07-15