str := '1996-8-9'; dat := StrToDate(Str); DecodeDate(dat,yy,mm,dd); 哈哈哈哈,^_^
我比较同意dbpower的方法,即: str := '1996-8-9'; dat := StrToDate(Str); yy := formatDateTime('yyyy',dat); mm := formatDateTime('mm',dat); dd := formatDateTime('dd',dat); 因为在delphi中是尽可能避免使用copy函数的,他牵涉到内存地址分配的问题,效率不高。 上述意见,仅供参考。
var present:TDateTime; Year,Month,Day:word; str,stryear,strmonth,strday:string; begin Present:=strtodate(str); Decodedata(Present,Year,Month,Day); stryear:=intTostr(Year); strmonth:=intTostr(Month); strday:=inttostr(Day);
str := '1996-8-9';
dat := StrToDate(Str);yy := formatDateTime('yyyy',dat);
mm := formatDateTime('mm',dat);
dd := formatDateTime('dd',dat);
mm=8
dd=9
Copy('1996-8-9',6,1)
Copy('1996-8-9',8,1)
dat := StrToDate(Str);
DecodeDate(dat,yy,mm,dd);
哈哈哈哈,^_^
str := '1996-8-9';
dat := StrToDate(Str); yy := formatDateTime('yyyy',dat);
mm := formatDateTime('mm',dat);
dd := formatDateTime('dd',dat);
因为在delphi中是尽可能避免使用copy函数的,他牵涉到内存地址分配的问题,效率不高。
上述意见,仅供参考。
present:TDateTime;
Year,Month,Day:word;
str,stryear,strmonth,strday:string;
begin
Present:=strtodate(str);
Decodedata(Present,Year,Month,Day);
stryear:=intTostr(Year);
strmonth:=intTostr(Month);
strday:=inttostr(Day);