怎样将TDateTime和2002-10-14 17:45:00这样的日期进行比较?(50分)

D

darzui

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样将TDateTime和2002-10-14 17:45:00这样的日期进行比较?
 
把字符串转换成TDateTime在比较
 
能不能具体举个例子?另外,delphi支持哪些日期格式?
 
StrToDate只能转换数字,所以你的字符串中有月份名,你就要使用VarToDateTime。这里是例子。
procedure TForm1.Button1Click(Sender: TObject);
var
DT : TDateTime;
begin
DT := VarToDateTime('December 6, 1969');
ShowMessage(FormatDateTime('yyyy-mm-dd hh:nn:ss', DT));
DT := VarToDateTime('6-Apr-1998');
ShowMessage(FormatDateTime('yyyy-mm-dd hh:nn:ss', DT));
DT := VarToDateTime('1998-Apr-6 12:34:00');
ShowMessage(FormatDateTime('yyyy-mm-dd hh:nn:ss', DT));
end;

 
接受答案了.
 
顶部