能否提供程序代碼參考.我用的以下方法,可是隻能查到2001的,2001/10或2001/10/24就查不到了.
function get_year:string;//年的函數
var
str_year,str_temp:string;
begin
str_year:=form1.ComboBox1.text;
if form1.ComboBox1.Text='' then
str_temp:=''
else
str_temp:=str_year;
result:=str_temp;
end;function get_month:string;//月的函數
var
str_month,str_temp:string;
begin
str_month:=form1.combobox2.text;
if form1.combobox2.text=''then
str_temp:=get_year//調用年
else
if get_year='' then
str_temp:=str_month
else
str_temp:=get_year+'/'+str_month;
result:=str_temp;
end;function get_all:string;//日的函數
var
str_day,str_temp:string;
begin
str_day:=form1.ComboBox3.Text;
if form1.ComboBox3.text='' then
str_temp:=get_month//調用年月
else
if get_month='' then
str_temp:=str_day
else
str_temp:=get_month+'/'+str_day;
result:=str_temp;
end;procedure TForm1.Button1Click(Sender: TObject);//查詢按鈕
var
str:string;
begin
str:=get_all;
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from employee where employee_indate like '+'''%'
+trim(str)+'%'+'''');
open;
end;
edit1.Text:=str;
form1.Print;
end;
function get_year:string;//年的函數
var
str_year,str_temp:string;
begin
str_year:=form1.ComboBox1.text;
if form1.ComboBox1.Text='' then
str_temp:=''
else
str_temp:=str_year;
result:=str_temp;
end;function get_month:string;//月的函數
var
str_month,str_temp:string;
begin
str_month:=form1.combobox2.text;
if form1.combobox2.text=''then
str_temp:=get_year//調用年
else
if get_year='' then
str_temp:=str_month
else
str_temp:=get_year+'/'+str_month;
result:=str_temp;
end;function get_all:string;//日的函數
var
str_day,str_temp:string;
begin
str_day:=form1.ComboBox3.Text;
if form1.ComboBox3.text='' then
str_temp:=get_month//調用年月
else
if get_month='' then
str_temp:=str_day
else
str_temp:=get_month+'/'+str_day;
result:=str_temp;
end;procedure TForm1.Button1Click(Sender: TObject);//查詢按鈕
var
str:string;
begin
str:=get_all;
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from employee where employee_indate like '+'''%'
+trim(str)+'%'+'''');
open;
end;
edit1.Text:=str;
form1.Print;
end;
解决方案 »
- d6中的qreport中打印设置的问题
- 一个ComboBox控件的问题!!~~~下班之前要搞定,忍住不上厕所在线急等!!~~
- 怎样把topendialog改造成topendirectorydialog?
- Memo中如何将新添加的一行选中?
- 请教 TMail2000 组件 发送邮件
- 感谢kl2000,接分!
- 求《Delphi网络高级编程》所附源码
- delphi6中image控件画布闪烁问题
- 谁有下面这些书其中之一的电子版,Email给我,马上给分!
- 数据库登陆密码怎么保存,我要在程序里面让用户可以修改密码,要单独的文件吗?急用!
- 如果用tinifile组件,希望程序中指定ini文件路径=程序路径
- Tedit问题,其实很简单不过我初学者:(,各位来帮忙。。。
SELECT * FROM EMPLOYEE WHERE EMPLOYEE_INDATE = ConVert(DateTime, ' + #39 + TRIM(STR) + #39 + ',101)
----------------------------------------------------------------
Wild Deer
+trim(str)+'%'+'''');
这句话有问题,如果你用的是SQLServer数据库,可以这样改:
sql.Add('select * from employee where convert(varchar,employee_indate,111) like '+'''%'
+trim(str)+'%'+'''');
直接通过判断是否为空,进行年月日的组合就Ok了!
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]
函数:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_fa-fz_2c1f.asp