Function GetDateID(i:integer;date:string):String;
var
Year, Month, Day:Word;
StrYear,StrMonth,StrDay:String;
begin
if date='next' then DecodeDate(Now+1, Year, Month, Day);
if date='prior' then DecodeDate(Now-1, Year, Month, Day);
if date='current' then DecodeDate(Now, Year, Month, Day);
if date='GLWZ' then DecodeDate(Now-0.33, 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);
case i of
0:Result:=StrYear+StrMonth+StrDay;
1:Result:=StrMonth+StrDay;
2:Result:=StrYear+'年'+StrMonth+'月'+StrDay+'日';
3:Result:=StrMonth+'月'+StrDay+'日';
4:Result:=StrDay+StrMonth;
end;
end;
用这个最简单
function GetAdd8(OldDatetime: TDatetime): TDatetime;
begin
result := OldDatetime - 1/3;//1/3就是8个小时
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Showmessage(DateTimeTostr(GetAdd8(Now)))
end;