Month of DecodeDate = Combobox1.ItemIndex or ......

解决方案 »

  1.   


    if month = combobox1.itemindex-1 then ...
    else ...
      

  2.   

    to hensenwu:
    procedure Tf_total_month.SpeedButton1Click(Sender: TObject);
    var
      Date:Tdatetime;
      year,month,day:word;
      str:string;
    begin
       adoquery1.close;
       adoquery1.sql.clear;
       adoquery1.SQL.add('select * from t_szb');
       adoquery1.Open;
       date:=adoquery1.fieldbyname('dtime').asdatetime;
       decodedate(date,year,month,day);
      if month=combobox1.itemindex-1 then
       begin
         adoquery2.Close;
         adoquery2.SQL.Clear;
         adoquery2.SQL.Add('select * from t_szb');
         adoquery2.SQL.Add('where 后面怎样写? ); //??????????????//
         adoquery2.Open;
         if adoquery2.RecordCount=0 then
           showmessage('没有数据!');
       end;end;
      

  3.   


    ( trim(cboYear1.text)+copy('00',1,2-length(trim(cboMonth1.text)))+trim(cboMonth1.text)+copy('00',1,2-length(trim(cboDay1.text)))+trim(cboDay1.text) )>( trim(cboYear2.text)+copy('00',1,2-length(trim(cboMonth2.text)))+trim(cboMonth2.text)+copy('00',1,2-length(trim(cboDay2.text)))+trim(cboDay2.text) )
      

  4.   

    可以这样实现:
    procedure Tf_total_month.SpeedButton1Click(Sender: TObject);
    var
      Date:Tdatetime;
      year,month,day:word;
      str:string;  MinDate, MaxDate: TDate;
      S_Date,E_Date : string;
      TempSQL : string;
    begin
      adoquery1.close;
      adoquery1.sql.clear;
      adoquery1.SQL.add('select * from t_szb');
      adoquery1.Open;
      date:=adoquery1.fieldbyname('dtime').asdatetime;
      decodedate(date,year,month,day);  if month=combobox1.itemindex-1 then
      begin
        adoquery2.Close;
        adoquery2.SQL.Clear;
     
        if Month=12 then
        begin
          MinDate := EncodeDate(year, month, 1);    
          MaxDate := EncodeDate(year+1, 1, 1);      
        end else
        begin
          MinDate := EncodeDate(year, month, 1);    //求得当前月份第一天
          MaxDate := EncodeDate(year, month+1, 1);  //求得当前月份下一月的第一天
        end;
        S_Date := FormatDateTime('MM''/''dd''/''yyyy', MinDate);
        E_Date := FormatDateTime('MM''/''dd''/''yyyy', MaxDate);
        TempSQL := Format('SELECT * FROM t_szb WHERE (Date>="%s") AND (Date<="%s")',[S_Date,E_Date]);    adoquery2.SQL.Clear;
        adoquery2.SQL.Add(TempSQL);
        adoquery2.RequestLive := True;
        adoquery2.Open;    if adoquery2.RecordCount=0 then
          showmessage('没有数据!');
      end;
    end;