怎样在本地取得SQL服务器上的时间,并能够对取得的时间进行操作。我知道用Getdate()来取得时间但不知道怎么把时间赋到自定义的变量中, 以便操作。(delphi)

解决方案 »

  1.   

    var
    aquery:TADOQuery;
    begin
      aquery:=TADOQuery.Create(Application);
      aquery.ConnectionString:=ADOConnection1.ConnectionString;
      with aquery do
      begin
        close;
        SQL.Clear;
        SQL.Add('select getdate() temdate');
        open;
        Edit1.Text:=aquery['temdate'];
      end;end;
      

  2.   

    with adoquery1 do
      begin
        close;
        sql.Clear;
        sql.Add('select getdate() as localtime');
        open;
      end;
      showmessage(datetimetostr(adoquery1.fieldbyname('localtime').AsDateTime));