输入变量ADateStart,并为其填写起始日期,变量ADateEnd,计算类型AType,
输出变量ADateStart,变量ADateEnd
 procedure FormatDateByType(AType:Integer; var ADateStart, ADateEnd: TDate);
procedure FormatDateByType(AType:Integer; var ADateStart, ADateEnd: TDate); var       //type 0日 1周 2月 3年
    var       //type 0日 1周 2月 3年 ADate :TDate;
      ADate :TDate; myYear, myMonth, myDay : Word;
      myYear, myMonth, myDay : Word; begin
    begin ADate := ADateStart;
      ADate := ADateStart; case AType of
      case AType of 0:begin  //日
        0:begin  //日 ADateStart := ADate;
          ADateStart := ADate; ADateEnd := ADate + 1;
          ADateEnd := ADate + 1; end;
        end; 1:begin  //周  DayOfWeek() Sunday =1
        1:begin  //周  DayOfWeek() Sunday =1 if DayOfWeek(ADate)<>2 then  // <> Monday
          if DayOfWeek(ADate)<>2 then  // <> Monday ADateStart := ADate - DayOfWeek(ADate) + 2
            ADateStart := ADate - DayOfWeek(ADate) + 2 else
          else ADateStart := ADate;
            ADateStart := ADate; ADateEnd := ADateStart + 6;  //周日
          ADateEnd := ADateStart + 6;  //周日 end;
        end; 2:begin  //月     xx-xx-01  to xx-yy-01
        2:begin  //月     xx-xx-01  to xx-yy-01 DecodeDate(ADate, myYear, myMonth, myDay);
          DecodeDate(ADate, myYear, myMonth, myDay); ADateStart := StrtoDate(inttostr(myYear) + '-' + inttostr(myMonth) + '-01');
          ADateStart := StrtoDate(inttostr(myYear) + '-' + inttostr(myMonth) + '-01'); ADateEnd := incmonth(ADateStart);
          ADateEnd := incmonth(ADateStart); end;
        end;                           3:begin  //年    xx-01-01  to yy-01-01
        3:begin  //年    xx-01-01  to yy-01-01 DecodeDate(ADate, myYear, myMonth, myDay);
          DecodeDate(ADate, myYear, myMonth, myDay); ADateStart := StrtoDate(inttostr(myYear)+'-01-01');
          ADateStart := StrtoDate(inttostr(myYear)+'-01-01'); ADateEnd := StrtoDate(inttostr(myYear+1)+'-01-01');
          ADateEnd := StrtoDate(inttostr(myYear+1)+'-01-01'); end;
        end; end;
      end; end;
    end;