用procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
试试
Returns Year, Month, and Day values for a TDateTime value.

解决方案 »

  1.   

    确定格式YYYY-MM-DD
    截出MM
    确定区间
      

  2.   

    function emontocmon():string;
     var xmonth:string;
        year,month,day:word;
        xdate:tdate;    
    begin    
        xdate:=datetimepicker1.date;
        decodedate(xdate,year,month,day);
        case month of 
        1:xmonth='4月份';
        ...
        12:xmonth='12月份';
        end;
        result:=xmonth;
    end;
      

  3.   

    uses
      DateUtils;procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
    begin
      Memo1.Clear;
      for I := MonthOf(StrToDate('2002-04-01')) to MonthOf(StrToDate('2002-08-09')) do
        Memo1.Lines.Add(Format('%d月份', [I]));
    end;
      

  4.   

    monthof(Tdatetime)
    Yearof(Tdatetime)
    Dayof(Tdatetime)
    weekof(Tdatetime)
      

  5.   

    y,m1,m2,d,i : word;
    decodedate(a,y,m1,d);
    decodedate(b,y,m2,d);
    for i := m1 to m2 do s := s := inttostr(i) + '月'#13;
    showmessage(s);
      

  6.   

    如果能肯定是 yyyy-mm-dd 格式的字符那就好办了:只要用字符串操作  Copy(a,6,2)+'月份' 就是你想要的值
    如要去掉月份前面的0则改成:       IntToStr(StrToInt(Copy(a,6,2)))+'月份'
      

  7.   

    因为是随机输入的日期,那么一般会要求一定的格式,起码,
    你可以使用EncodeDate把录入的转换为日期型(也许录入时
    就已经是日期型的),然后使用FormatDatetime函数转化格
    式为'yyyy-mm-dd',按照楼上的做法补全中间的月份就行了。