Skip to main content

AsDateTime

property AsDateTime: TDateTime read write

Example

procedure ScriptEvent(var Value: variant);
begin
if Field.IsDateType and Field.NotNull then
Value := Field.AsDateTime
else
Value := Null;
end;

Usage

Reads or writes the field using Velox date/time conversion rules.

Additional Technical Info

AsDateTime exposes a read/write Delphi TDateTime value.

Velox implements both accessors as TDateTimeField(Self).AsDateTime. That is a static cast only: it performs no runtime is TDateTimeField check and does not change the object. TField.AsDateTime accessors are virtual, so the actual field descendant still determines what happens.

For date/time descendants, reads and writes use their normal date/time representation. Other descendants may supply a supported conversion—for example a string field can parse/format date text—or may raise the inherited field access/conversion error. Locale and field formatting can affect text-backed conversion. IsDateType is a prudent guard when only Velox's four recognized date/time types should be accepted, but it is not a universal conversion-capability test.

Null reads follow the actual typed-field behavior; Delphi typed reads commonly return type default 0, so test IsNull when database null must remain distinct from the Delphi date/time zero value.

Writing invokes the concrete field setter, can require edit/insert state, perform parsing/range/validation work, mark the record modified or raise. It does not post or commit. The operation acts on the current cursor record and the dataset owns the field.

External references

Created 2026-07-15