1、双击Query或Table,选择字段类型为Datetime的字段
2、displayformat --- yyyy"/"mm"/"dd
3、Editmask -- !9999/99/00;1;_
4、在该字段的OnGetText事件:
if Sender is TDatetimeField then
begin
if (FormatDatetime('yyyy"/"mm"/"dd',Sender.AsDateTime) ='1899/12/30') then Text :=''
else Text :=FormatDatetime('yyyy"/"mm"/"dd',Sender.AsDateTime);
end;
5、在该字段的OnSetText事件:
try
if Sender is TDatetimeField then
Sender.AsDateTime :=StrToDatetime(Text);
except
Showmessage('Error TDatetime ');
end;
6、OK!