全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1233
推到 Plurk!
推到 Facebook!

Select where Datetime

尚未結案
Delilama
一般會員


發表:5
回覆:11
積分:3
註冊:2003-06-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-26 18:05:15 IP:203.184.xxx.xxx 未訂閱
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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-26 18:20:03 IP:211.76.xxx.xxx 未訂閱
hi try htis strsql := 'select * from tableA where updatetime >= ''#' gdatetime '#'''; ~~應無所住而生其心~~
Delilama
一般會員


發表:5
回覆:11
積分:3
註冊:2003-06-30

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-27 02:17:17 IP:221.127.xxx.xxx 未訂閱
>>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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-03-27 15:04:08 IP:218.15.xxx.xxx 未訂閱
你好: 你设个断点,看看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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-03-29 09:39:35 IP:147.8.xxx.xxx 未訂閱
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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-03-29 17:07:48 IP:203.184.xxx.xxx 未訂閱
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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-03-29 17:15:47 IP:203.184.xxx.xxx 未訂閱
Yes ... i got it ... I know how to pass parameters. Thx both of you ..
系統時間:2024-05-19 3:29:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!