这个代码怎么不对?? edit1.Text:=datetostr(incmonth(2006/11/25));为什么显示的1900-02-06而edit1.Text:=datetostr(date);确可以显示2006-11-25怎么回事啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哈哈哈,incmonth(2006/11/25))你知道你这里的两个'/',表示什么吗?是除号!你要先用字符串转成日期型,再用incmonth edit1.Text:=datetostr(incmonth(strtodate('2006-11-25'))); 小胡桃怎么又开一帖呢?这个回复免费,不要分。(你去看看你另外的一帖)procedure TFormDate.ButtonDateClick(Sender: TObject);var _Date: TDateTime; _Str: string; _DateAddYear: string; _DateAddMonth: string; _DateAddDay: string; _Year, _Month, _Day: Word; _Strings: TStrings;begin _Str := '2005/10/20'; _Strings := TStringList.Create; _Strings.Delimiter := '/'; _Strings.DelimitedText := _Str; try try _Year := StrToInt(_Strings[0]); _Month := StrToInt(_Strings[1]); _Day := StrToInt(_Strings[2]); _Date := EnCodeDate(_Year, _Month, _Day); _DateAddYear := FormatDateTime('YYYY/MM/DD', DateUtils.IncYear(_Date, 1)); _DateAddMonth := FormatDateTime('YYYY/MM/DD', DateUtils.IncMonth(_Date, 1)); _DateAddDay := FormatDateTime('YYYY/MM/DD', DateUtils.IncDay(_Date, 1)); except ShowMessage(_Str+'不是有效日期'); end; finally _Strings.Free; end;end; 求注解 自己基于bpl开发的delphi框架源码,欢迎下载 二进制文件操作 如何实现两张图片的渐变? Com+Oracle的提交问题 关于在DBGRIDEH中输入日期和时间问题 紧急求救我现在要做的报表比一般的报表要长的多大概是1500吧我要怎么处理呢 nstallShield2003打包的exe安装文件如何解包 在DELPHI中如何使用SQL语句中的连接字符串的功能,我试了CONCAT和‘||’都不行,该怎么办? 熟悉Delphi编译器设置的请进? 怎么样才能使代码和界面完全的分开呢? 动态创建button按钮问题.....
incmonth(2006/11/25))
你知道你这里的两个'/',表示什么吗?
是除号!你要先用字符串转成日期型,再用incmonth
var
_Date: TDateTime;
_Str: string;
_DateAddYear: string;
_DateAddMonth: string;
_DateAddDay: string;
_Year, _Month, _Day: Word;
_Strings: TStrings;
begin
_Str := '2005/10/20';
_Strings := TStringList.Create;
_Strings.Delimiter := '/';
_Strings.DelimitedText := _Str;
try
try
_Year := StrToInt(_Strings[0]);
_Month := StrToInt(_Strings[1]);
_Day := StrToInt(_Strings[2]);
_Date := EnCodeDate(_Year, _Month, _Day);
_DateAddYear := FormatDateTime('YYYY/MM/DD', DateUtils.IncYear(_Date, 1));
_DateAddMonth := FormatDateTime('YYYY/MM/DD', DateUtils.IncMonth(_Date, 1));
_DateAddDay := FormatDateTime('YYYY/MM/DD', DateUtils.IncDay(_Date, 1));
except
ShowMessage(_Str+'不是有效日期');
end;
finally
_Strings.Free;
end;
end;