#1 2011-10-05 11:10:00

noobies
Member
Registered: 2011-09-13
Posts: 139

how write null value to TDateTime?

It is often necessary to leave the date blank
use ADO i write

if query.FieldByName('DATE_BL').IsNull then dedtDATE_B.Clear
else dedtDATE_B.Date := FieldByName('DATE_BL').AsDateTime;

i write procedure, but i think is a bad way to check null datetime

procedure ReadDate(dedt: TRzDateTimeEdit; d: TDateTime);
begin
  if DatetoStr(d) = '30.12.1899' then dedt.Clear
  else dedt.Date := d;
end;

Last edited by noobies (2011-10-05 11:27:17)

Offline

#2 2011-10-05 11:28:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: how write null value to TDateTime?

Why not just:

if d=0 then dedt.clear else dedt.Date := d;

Offline

#3 2011-10-06 05:16:23

noobies
Member
Registered: 2011-09-13
Posts: 139

Re: how write null value to TDateTime?

WOW is pretty simple, thanks!

Offline

Board footer

Powered by FluxBB