select * from table where sometime > '2001-01-01'

解决方案 »

  1.   

    看看下面代码有一个条件是按时间的。procedure TF_3.Button1Click(Sender: TObject);
    Var
            Conditions , B_name , OptionChar , FieldName : String ;
            BeginT , EndT , UseT : Real ;
    begin
            FieldName := 'blid as 病历号 , bpatid as 检查号 ' ;
            for i := 0 to Length( Field ) - 1 do begin
                    if Field[i].useed then
                            FieldName := FieldName +  ' , ' + Field[i].field_en + ' as ' + Field[i].field_china  ;
            end ;
            //Delete( FieldName , Length( FieldName ) - 1 , 1 ) ;//        if FieldName = '' then
    //                FieldName := 'bpatname as 病人姓名' ;
            //ShowMessage( FieldName ) ;
            OptionChar := SpeedButton5.Caption ;
            B_name := Edit20.Text ;
            F_0.DataSource1.DataSet := F_0.ADOQuery1 ;
            Conditions := ' and ( bdate ' + OptionChar + '''' + DateToStr( DateTimePicker1.Date )  + '''' ;
            if   B_name = '' then
                    Conditions := Conditions + ')'
            else begin
                    if CheckBox1.Checked then
                            Conditions := Conditions + ' and bpatname like  ' + '''' + '%' + B_name + '%' + ''''  + ' )'
                    else
                            Conditions := Conditions + ' and bpatname =  ' + '''' + B_name  + ''''  + ' )' ;        end ;
            BeginT := GetTickCount ;
            With F_0.ADOQuery1 do begin
                    Close ;
                    SQL.Clear ;
                    if F_1.LoginParameters.UserName = '超级管理员' then
                            SQL.Add( 'select count(blid) from history where bdrname <> ' + '''' + '''' + Conditions  )
                    else
                            SQL.Add( 'select count(blid) from history where bdrname like ' + '''' + '%' + F_1.LoginParameters.UserName + '%' + ''''  + Conditions  );
    //                ShowMessage( SQL.Text ) ;
                    Open ;
                    Label3.Caption := '数目:' + Fields[0].AsString + ' 条' ;
            end ;        With F_0.ADOQuery1 do begin
                    Close ;
                    SQL.Clear ;
                    if F_1.LoginParameters.UserName = '超级管理员' then
                            SQL.Add( 'select ' + FieldName + ' from history where bdrname <> '  + '''' + '''' + Conditions  )
                    else
                            SQL.Add( 'select ' + FieldName + ' from history where bdrname like ' + '''' + '%' + F_1.LoginParameters.UserName + '%' + ''''  + Conditions  );
    //                ShowMessage( SQL.Text ) ;
                    Try
                            Open ;
                    Except
                            Application.MessageBox( '您的查询失败,原因可能是某列无效!' , '提示' , MB_OK + MB_ICONINFORMATION ) ;
                    End ;
            end ;        EndT := GetTickCount ;
            UseT := EndT - BeginT ;
            UseT :=  Round( ( UseT / 1000 )  * 100 ) / 100 ;
            Label11.Caption := '【' + CurrToStr( UseT ) + ' 秒】' ;
    end;