请问,这个SQL语句在Delphi里怎么写?

我想检索7天内所有记录,不知道时间参数在Delphi中怎么写,
把时间转换成字符串有问题。
[51 byte] By [wushenjian-生活在远方] at [2008-2-13]
# 1
用timetostr()函数
yinweicai-人之虎 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 2
sql.clear;
sql.add('select * from tablename where datefield between :BDate and :EDate');

parambyname('BDate').AsDate := currentdate;
parambyname('EDate').AsDate := currentdate - 7;
chutian-我很丑??? at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 3
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add ('select field1 from ATable');
SQL.Add ('where TimeField = :time');
ParamByName('time').AsDateTime := FormatDateTime ('yyyy-mm-dd', ADateTimeTypeValue);//FormatDateTime()格式化成你所需要的日期格式,参考Delphi的在线帮助。
Prepare;
try
Open;
...
...
finally
Close;
end;
end;
# 4
刚才上面写的有点错误,大致如前者。
# 5
Query.active:=false;
Query.SQL.clear;
Query.SQL.Add('Select Clo From Table where date between '+''''+DateToStr(BeginDate)+''''+' and '+''''+ DateToStr(EndDate)+'''');
Query.Active:=true;
SayForever-恒 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 6
DateTimeToString() 将日期时间格式转换为字符串
DateToStr() 将日期格式转换为字符串
Time() 返回当前的时间
TimeToStr() 将时间格式转换为字符串

lyyrw-咋暖还寒 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 7
多谢各位!我试一下先,回头再散分!
# 8
使用结果报告:
chutian(kiss you) 和wangchinaking(Deemon)的思路跟我想的一样,
但行不通。SayForever(恒) 的意见没有问题。
此贴到此为止。请各位注意接分。