Z zero2001 Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-17 #1 ①如何计算两个日期之间的天数(如:00-8-23到01-2-24)??
阿 阿梁 Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-17 #5 var d:tdatetime; v1,v2:SYSTEMTIME; begin d:=DateTimePicker1.Date; DateTimeToSystemTime(date,v1); DateTimeToSystemTime(d,v2); showmessage(inttostr( v1.wday-v2.wday ));
var d:tdatetime; v1,v2:SYSTEMTIME; begin d:=DateTimePicker1.Date; DateTimeToSystemTime(date,v1); DateTimeToSystemTime(d,v2); showmessage(inttostr( v1.wday-v2.wday ));
X xxhsh Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-17 #7 楼上的讲的有问题,它只是对天数作了相减! 8.17-8.1=16 8.17-7.31=-14 明显不对!!!!!!!!!
C Calvin75 Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-17 #9 var d1, d2: TDateTime; begin Result := Round(d2 - d1); end;
光 光子 Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-17 #11 是直接相减,我的程序试验的结果如下 DateTimePicker1 DateTimePicker2 差 2001-8-18 2001-8-17 1 2002-1-15 2001-8-17 151 2002-10-1 2001-8-17 410 程序片断: procedure TForm1.Button1Click(Sender: TObject); var s:string; begin Str(DateTimePicker1.DateTime-DateTimePicker2.DateTime:0:0, s); Edit1.Text:=s; end;
是直接相减,我的程序试验的结果如下 DateTimePicker1 DateTimePicker2 差 2001-8-18 2001-8-17 1 2002-1-15 2001-8-17 151 2002-10-1 2001-8-17 410 程序片断: procedure TForm1.Button1Click(Sender: TObject); var s:string; begin Str(DateTimePicker1.DateTime-DateTimePicker2.DateTime:0:0, s); Edit1.Text:=s; end;