各位大虾: 我想用datetimepicker来查询一段日期的数据访问sqlserver中的一个表中的smalldatetime字段的数据;用的是ADO连接 语句如下: var d1,d2,s1:string;
d1:=datetimetostr(datetimepicker1.datetime)
d2:=datetimetostr(datetimepicker2.datetime)
s1:='select * from danju where danju.endtime>=d1 and danju.endtime<d2 但程式运行会说列名‘d1'无效,不知各位是如何把datetimepicker中的日期给到sql语句中的 多谢各位赐教!
d1:=datetimetostr(datetimepicker1.datetime)
d2:=datetimetostr(datetimepicker2.datetime)
s1:='select * from danju where danju.endtime>=d1 and danju.endtime<d2 但程式运行会说列名‘d1'无效,不知各位是如何把datetimepicker中的日期给到sql语句中的 多谢各位赐教!
解决方案 »
- 在FastReport中如何实现动态列
- delpih 6 文件保存失败,不是简单的问题,请教高手
- 请问如何在DELPHI把系统时间加入到SQL Server中
- 100分奖励:如何让1、2、3发出声音do,re,mi
- 怎么办?过来人给点意见!来者有分!
- 靠,几天没来,我的信誉分大减。放分。
- 怎样把一个.mdf和.ldf文件导入sql server 2000里啊!
- 为什么在我的quickrep中不能显示出来指定的图片?
- 在Delphi中如何实现VC中的CRectTracker类
- paradox数据库正在存数据的时候突然断电!在从新启动机器数据库就坏了,请问有什么处理方法???
- Delphi5+MyODBC+Query 修改数据错误!请大家帮忙!
- COM+求救.
你可以直接用datetimepicker1.datetime用为日期就可以了
'select * from danju where endtime>=datetimepicker1.datetime and endtime<datetimepicker2.datetime
没有验证,自己再看看吧
adoquery1.sql.add(s1);
adoquery1.Parameters.ParamByName('d1').Value:=d1
adoquery1.Parameters.ParamByName('d2').Value:=d2
Sql:='Select * from 表 where 时间>'+D1+' and 时间<'+D2
BEGIN
Close ;
ParamByName('name').ASSTRING := name.KeyValue ;
ParamByName('S_DATE').AsDatetime := DateTimePicker3.DateTime ;
ParamByName('E_DATE').AsDatetime := DateTimePicker4.DateTime ;
open ;
end;
function FormatDateTime(const Format: string; DateTime: TDateTime; const FormatSettings: TFormatSettings): string; overload;C++ syntax:extern PACKAGE AnsiString __fastcall FormatDateTime(const AnsiString Format, System::TDateTime DateTime);
extern PACKAGE AnsiString __fastcall FormatDateTime(const AnsiString Format, System::TDateTime DateTime, const TFormatSettings FormatSettings);DescriptionFormatDateTime formats the TDateTime value given by DateTime using the format given by Format. See Date-Time format strings for more information.If the string specified by the Format parameter is empty, the TDateTime value is formatted as if a 'c' format specifier had been given.The first form of FormatDateTime is not thread-safe, because it uses localization information contained in global variables. The second form of FormatDateTime, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of FormatDateTime, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings.
FormatDateTime函数进行指定的日期和时间形式的格式化,一次来符合你的数据库日期和时间格式的特殊要求!formatdatetime('yyyy-mm-dd hh:mm:ss',datetimepicker1.datetime)
这样就是一个例子阿!!