日期问题 我现在有一个差值(整型的),还有一个日期型的(当天的日期),我想得到今天的日期加上这个差值以后的日期。怎么实现?我得到的总是2003-10-31 1:0:0!!!!(其中的1是我得到的差值) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先DecodeDate()后加上差值 再EncodeDate(Year, Month, Day: Word): TDateTime; var date:TDateTime;begin date := now + 1; showmessage(datetimetostr(date));end; 给你贴段delphi的代码procedure TForm1.Button1Click(Sender: TObject);var Present: TDateTime; Year, Month, Day, Hour, Min, Sec, MSec: Word; begin Present:= Now; DecodeDate(Present, Year, Month, Day); Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month ' + IntToStr(Month) + ' of Year ' + IntToStr(Year); DecodeTime(Present, Hour, Min, Sec, MSec); Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour ' + IntToStr(Hour);end;运行一下你就知道decodedate的作用了,然后可以根据你的要求在上面加上差值了,如果还要时间的话就用DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word);这是encodedate的例子rocedure TForm1.Button1Click(Sender: TObject);var MyDate: TDateTime;begin MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text)); Label1.Caption := DateToStr(MyDate);end;应该能明白了吧 showmessage(datetimetostr(date + 1)); 根本没你说的现象 关于delphi xe JSON方便的几个注意事项。 如何实现串口的实时接受 ====请问如何做出象Excel中的单元格计算公式一样的效果。====在线等 请问那位有现成的数据备份和恢复的文件,我是初学者,请帮忙!我的E-mail:[email protected],在此先谢谢各位了! XE6 里的 TLang 是国产货吗? 请问怎样完成象开始菜单的外观即左边有一竖条且COLOR可变 很简单的一个问题! 如何拦截API? 别人回答对了,我如何给分?如何确定该问题已解决? 在报表中用不同的颜色代表不同类型的记录(急、急、急) 窗体与分辨率问题,在线等 QuickReport控件的简单问题!!
再EncodeDate(Year, Month, Day: Word): TDateTime;
date:TDateTime;
begin
date := now + 1;
showmessage(datetimetostr(date));
end;
procedure TForm1.Button1Click(Sender: TObject);var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;
运行一下你就知道decodedate的作用了,然后可以根据你的要求在上面加上差值了,如果还要时间的话就用DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word);
这是encodedate的例子
rocedure TForm1.Button1Click(Sender: TObject);var
MyDate: TDateTime;
begin
MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
Label1.Caption := DateToStr(MyDate);
end;
应该能明白了吧
根本没你说的现象