关于数据库中日期类型数据比较问题!急!!!

KingI 2005-11-18 09:44:03
在dephi中的要比较日期类型的数据,应该用什么格式?
比如:
要查找日期为2005-10-12日的数据
sql.add('select * from table where 日期='?'');
'?'处应该用什么格式写出要比较的日期?
...全文
118 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
catfather46 2005-11-18
  • 打赏
  • 举报
回复
Paradox:
'select * from aa where (EnterTime>='+''''+FormatDateTime('mm',EnterTimeDTP.DateTime)+
'/'+FormatDateTime('dd',EnterTimeDTP.DateTime)+'/'+FormatDateTime('yyyy',EnterTimeDTP.DateTime)+
' 00:00:00:00'+''''+') ';
Access:
decodeDate(DateTimePicker1.DateTime,yyyy,mm,dd);
tempsql:='select * from aa where 日期 Between '+'#'+inttostr(mm)+'/'+inttostr(dd)+'/'+inttostr(yyyy)+'# And ';
decodeDate(DateTimePicker2.DateTime,yyyy,mm,dd);
tempsql:=tempsql+'#'+inttostr(mm)+'/'+inttostr(dd)+'/'+inttostr(yyyy)+'#')
smiler007 2005-11-18
  • 打赏
  • 举报
回复
sql.add('select * from table where 日期=:xDate');
Parameters[0].Value:=StrToDate(Edit1.Text);
Open;

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧