我要查employee表中什麼時間進廠的員工的信息.字段是employee_indate(此字段在sql中定義為datetime類型.)下面意思是我從combobox1中選擇了"入廠日期".之後在edit_search中輸入了入廠時間.如2001/10/24.之後按查詢.
var
d:tdatetime;
if combobox1.ItemIndex=2 then
begin
d:=strtodatetime(edit_search.Text);
with adoq_rsquery do
begin
close;
sql.Clear;
sql.Add('select * from employee where employee_indate=''d''');
open;
end;
end;
可是出現"syntax error converting datetime from character string.請問各位應怎樣轉換.
var
d:tdatetime;
if combobox1.ItemIndex=2 then
begin
d:=strtodatetime(edit_search.Text);
with adoq_rsquery do
begin
close;
sql.Clear;
sql.Add('select * from employee where employee_indate=''d''');
open;
end;
end;
可是出現"syntax error converting datetime from character string.請問各位應怎樣轉換.
对于变量应该放到字符串的外面,并且要转化成string形式。
我觉得楼上老兄说的应该对了
adoq_rsquery.sql.Add('select * from employee where employee_indate=:date1);
adoq_rsquery.parambyname('date1').asdate:=d;
============================
@* .☆ / */ . / * . ☆/ *。
◢◣。 ◢◣。
◢★◣。 ◢★◣。
◢■■◣。 ◢■■◣。
◢■■■◣。 ◢■■■◣。
︸︸||︸︸ !!︸︸||︸︸
愿您有快乐的每一天 ^_^!!
提示是undeclared identifier "formatdate".
怎麼回事啊,各位
'select * from employee where employee_indate='+StrToDate(edit_search.Text)+''''
sql.Add('select * from employee where employee_indate='+''''+Trim(edit_search.Text)+'''');
'formatdate'應該是formatDateTime()是一個轉換日期格式的函數。