function GetPreDate(FormatDate: string): string;//获得上一个月
var
year, mon: string;
IntMon: integer;
begin
if length(FormatDate) > 10 then
begin
Application.MessageBox('日期格式出错', '警告', MB_OK + MB_ICONEXCLAMATION);
Abort;
end;
IntMon := strtoint(copy(FormatDate, 6, 2));
year := copy(FormatDate, 1, 4);
case IntMon of
1:
begin
mon := '12';
year := inttostr(strtoint(year) - 1);
end;
2: mon := '01';
3: mon := '02';
4: mon := '03';
5: mon := '04';
6: mon := '05';
7: mon := '06';
8: mon := '07';
9: mon := '08';
10: mon := '09';
11: mon := '10';
12: mon := '11';
end;
result := year + '-' + mon + '-' + Copy(FormatDate, 9, 2);
end;
function GetNextDate(FormatDate: string): string;//获得下一个月
var
year, mon: string;
IntMon: integer;
begin
if length(FormatDate) > 10 then
begin
Application.MessageBox('日期格式出错', '警告', MB_OK + MB_ICONEXCLAMATION);
Abort;
end;
IntMon := strtoint(copy(FormatDate, 6, 2));
year := copy(FormatDate, 1, 4);
case IntMon of
1: mon := '02';
2: mon := '03';
3: mon := '04';
4: mon := '05';
5: mon := '06';
6: mon := '07';
7: mon := '08';
8: mon := '09';
9: mon := '10';
10: mon := '11';
11: mon := '12';
12:
begin
mon := '01';
year := inttostr(strtoint(year) + 1);
end;
end;
result := year + '-' + mon + '-' + Copy(FormatDate, 9, 2);
end;