在sql server中插入时间记录是用Now()函数,即时间字段的记录是有日期和时间。
我用DateTimePicker来查询库中的数据,只需要查日期,
使用如下语句,怎么查询不出。是不是因为字段中还有时间的原因?
该如何把处理字段中的时间?
SQL.Add('select 字号 from Table1 where 时间=:sd');
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
我用DateTimePicker来查询库中的数据,只需要查日期,
使用如下语句,怎么查询不出。是不是因为字段中还有时间的原因?
该如何把处理字段中的时间?
SQL.Add('select 字号 from Table1 where 时间=:sd');
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
解决方案 »
- 字符串解析的问题,我该如何解析字符串中的表达式并求值?
- 怎样使delphi写的控制台程序在使用中密码显示星号?
- 我如何让listview不选中某一行?
- 数据库连接不上.
- Delphi里如何才能准确地获得中文字符串的长度?
- 在TCHART的mousedown事件里如何得到TCHART中Series1上的点的索引值?
- 狂发帖,分太少没人问?可怜的人........高手帮我
- 初学Delphi 7,怎么使用代码安全工具啊
- 哪里有delphi6.0 sp2 ???
- TTable 的Locate 部分匹配不对劲
- 在不同的form上用不同的table操作同一个access数据库表为什么不行??
- 能不能让单选按钮前面的圈圈变大点?
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);date函数在sql语句中;就是将时间字段取日期值;利用这个函数可以搞定;另外建议朋友以后保存时间的时候不要用time();函数;
要用date();;^_^;
Parameters.ParamByName('sd').Value:=DateTimePicker1.Date;或
SQL.Add('select 字号 from Table1 where convert(char(10),时间,120)=:sd');
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
也許都不太好,如果不需要時間﹐保存時就保存Date
adoquery1.clear;
adoquery1.text:='SELECT * FROM TABLE WHERE date>='''+DATETO STR(TIME1)+''''+' AND TIME<='+DATETOSTR(TIME2)+'''';
adoquery1.open;
SQL.Add('select 字号 from Table1 where date(时间)=:sd');
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
SQL.Add('select 字号 from Table1 where 时间>=:sd and 时间<=:ed');
Parameters.ParamByName('sd').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
Parameters.ParamByName('ed').Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date+1);这样查询的就是一天之内的时间了,可惜不能给自己加分。
多谢回答。揭贴!