Function GetDateID(i:integer;date:string):String; var Year, Month, Day:Word; StrYear,StrMonth,StrDay:String; begin DecodeDate(Now, Year, Month, Day); if Year<10 then StrYear:='0'+IntToStr(Year) else StrYear:=IntToStr(Year); if Month<10 then StrMonth:='0'+IntToStr(Month) else StrMonth:=IntToStr(Month); if Day<10 then StrDay:='0'+IntToStr(Day) else StrDay:=IntToStr(Day);
var
Year, Month, Day: Word;
begin
DecodeDate(CurDate, Year, Month, Day);
end;
...
decodedate(y,m,d,Date):
...
decodedate(Date,y,m,d);
你试试!
y,m,d word;
yy,mm,dd string
decodedate(date,y,m,d)
yy:=string(y)
....
....
showmessage(yy)
showmessage(inttostr(y));
Year, Month, Day: Word;
begin
DecodeDate(CurDate, Year, Month, Day);
end;
DecodeDate 和EncodeDate相对应,一个是分开,一个是合并日期。
decodedate(date,y,m,d)
yy:=string(y)
....
....
showmessage(yy)y是word型,yy:=string(y)错误编译不过~~~我试过了怎么弄告诉我~
var
Year, Month, Day:Word;
StrYear,StrMonth,StrDay:String;
begin
DecodeDate(Now, Year, Month, Day);
if Year<10 then StrYear:='0'+IntToStr(Year)
else StrYear:=IntToStr(Year); if Month<10 then StrMonth:='0'+IntToStr(Month)
else StrMonth:=IntToStr(Month); if Day<10 then StrDay:='0'+IntToStr(Day)
else StrDay:=IntToStr(Day);
Result:=StrYear+StrMonth+StrDay;
end;
这里的now是返回当前时间 可以用你自己的date试试