//我刚刚帮你写的 Function TForm1.Split(ddatetime: Datetime): String; var i:integer; site:integer; tmp:string; Buf:String; begin Buf:=datetimetostr(ddatetime); site:=1; for i:=1 to length(buf) do begin if buf[i]='-'then begin tmp:=copy(buf,site,i-site); if length(tmp)=1 then tmp:='0'+tmp; Result:=Result+tmp; site:=i+1; end; end; tmp:=copy(buf,site,i); if length(tmp)=1 then tmp:='0'+tmp; Result:=Result+tmp; end; 传入你的日期返回string
//我刚刚帮你写的 Function TForm1.Split(ddatetime: Datetime): String; var i:integer; site:integer; tmp:string; Buf:String; begin Buf:=datetimetostr(ddatetime); site:=1; for i:=1 to length(buf) do begin if buf[i]='-'then begin tmp:=copy(buf,site,i-site); if length(tmp)=1 then tmp:='0'+tmp; Result:=Result+tmp; site:=i+1; end; end; tmp:=copy(buf,site,i); if length(tmp)=1 then tmp:='0'+tmp; Result:=Result+tmp; end; 传入你的日期返回string
S := FormatDateTime('yyyy-mm-dd', StrToDate('02-2-3')); S := StringReplace(S, '-', '', [rfReplaceAll]);
Function TForm1.Split(ddatetime: Datetime): String;
var
i:integer;
site:integer;
tmp:string;
Buf:String;
begin
Buf:=datetimetostr(ddatetime);
site:=1;
for i:=1 to length(buf) do
begin
if buf[i]='-'then
begin
tmp:=copy(buf,site,i-site);
if length(tmp)=1 then
tmp:='0'+tmp;
Result:=Result+tmp;
site:=i+1;
end;
end;
tmp:=copy(buf,site,i);
if length(tmp)=1 then
tmp:='0'+tmp;
Result:=Result+tmp;
end;
传入你的日期返回string
Function TForm1.Split(ddatetime: Datetime): String;
var
i:integer;
site:integer;
tmp:string;
Buf:String;
begin
Buf:=datetimetostr(ddatetime);
site:=1;
for i:=1 to length(buf) do
begin
if buf[i]='-'then
begin
tmp:=copy(buf,site,i-site);
if length(tmp)=1 then
tmp:='0'+tmp;
Result:=Result+tmp;
site:=i+1;
end;
end;
tmp:=copy(buf,site,i);
if length(tmp)=1 then
tmp:='0'+tmp;
Result:=Result+tmp;
end;
传入你的日期返回string
S := StringReplace(S, '-', '', [rfReplaceAll]);
ShortDateFormat:='yyyy-mm-dd'; //设置系统的短日期格式为 年-月-日
s:=formatdatetime('yyyymmdd', strtodate('2002-02-03'));
Showmessage(S);