肯定不可以:
sizeof(tdatetime) = 8 而 sizeof(integer) = 4
不过你可以用两个 integer(如 int64) “完全精确”地保存时间:
function DataTimeToInt64(const ADateTime: TDateTime): Int64;
begin
Move(ADateTime, Result, SizeOf(Result));
end;
function Int64ToDataTime(const AInt: Int64): TDateTime;
begin
Move(AInt, Result, SizeOf(Result));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S, T: TDateTime;
I: Int64;
begin
T := Now;
I := DataTimeToInt64(T);
S := Int64ToDataTime(I);
Caption := BoolToStr(CompareMem(@S, @T, SizeOf(TDateTime)), True);
end;