Select where Datetime |
尚未結案
|
Delilama
一般會員 發表:5 回覆:11 積分:3 註冊:2003-06-30 發送簡訊給我 |
I got a error from the following sql using Access2000 and delphi gDateTime := formatdatetime('yyyy/mm/dd hh:nn:ss',strtodatetime(wdsdatamodule.wdsDSConfig.FieldValues['UpdateTime'])); strsql := 'select * from tableA where updatetime >= ' gdatetime ;
wdsClientDataSet1.CommandText := strsql;
wdsClientDataSet1.Active := true; Whatever I try
strsql := 'select * from tableA where updatetime >= #' gdatetime '#';
or
strsql := 'select * from tableA where updatetime >= ''' gdatetime ''''; still have error. can anybodies tell me how to run sql in delphi using compare datetime ?? Thx sooo much
|
terrychen
尊榮會員 發表:90 回覆:794 積分:501 註冊:2003-05-01 發送簡訊給我 |
|
Delilama
一般會員 發表:5 回覆:11 積分:3 註冊:2003-06-30 發送簡訊給我 |
>>strsql := 'select * from tableA where updatetime >= #' gdatetime '#'; thx for your reply first, actually , i tried this b4, and the error told me "Arguments error" something like that. Is it work for whole 'yyyy/mm/dd hh:nn:ss' in where comparison ?
|
deity
尊榮會員 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
你好:
你设个断点,看看gDateTime 的值对不对
showmessage(gDateTime);
gDateTime没问题的话,你可以试试下面这种方法:
begin
strsql := 'select * from tableA where updatetime >=:rq1;
wdsClientDataSet1.CommandText := strsql;
end;
wdsClientDataSet1.Params [0].DataType :=ftDateTime;
wdsClientDataSet1.Params [0].Value:=rq1;
wdsClientDataSet1.Active := true;
试试看行不行 ——行径窄处,留一步与人行—— 發表人 -
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
No need to convert datetime to string in using Delphi and Access. Datetime is stored as floating point and you can treat is as floating point, e.g. strsql := 'select * from tableA where updatetime >= :gdatetime'; then pass the parameter gdatetime to the query component you use. P.S. It seems that noth Access and Delphi both use the same format and the date calculated is based on 12/30/1899, so there is no need for conversion.
|
Delilama
一般會員 發表:5 回覆:11 積分:3 註冊:2003-06-30 發送簡訊給我 |
Thx for your reply first, but i am really new in delphi.
can i ask how to use with ":" and gdatetime ??
strsql := 'select * from tableA where updatetime >= :gdatetime'; I got a error "Parameter Object is improperly defined", how to resolve it.
|
Delilama
一般會員 發表:5 回覆:11 積分:3 註冊:2003-06-30 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |