急DataTimePicker1控件的用法。。。。 ( 积分: 50 )

  • 主题发起人 主题发起人 honday
  • 开始时间 开始时间
H

honday

Unregistered / Unconfirmed
GUEST, unregistred user!
我在DELPHI中新建了一个窗体,已经用ADO控件连接到数据库,建了二个查询的选择条件:
“盘点日期”:用DataTimePicker1控件代替
“商品编码”:Edit.Text控件代替

在“查询”中写入代码:
adoquery1.SQL.Add('select a.dInventoryDate,b.sGoodsNO,a.sShelfNO,a.nCountQty,a.nCheckQty,a.nConfirmQty
from tInventoryDtl a, tGoods b
where a.nGoodsID=b.nGoodsID
and a.dInventoryDate=DataTimePicker1.date
and b.sGoodsNO='''+Edit1.Text+'''')
这个a.dInventoryDate字段的类型是datetime,请问如何在语句中表述出来,摸索了几天都没做出来,有会的朋友指点一下,多谢啦!(好急)
 
adoquery1.SQL.Add('select a.dInventoryDate,b.sGoodsNO,a.sShelfNO,a.nCountQty,a.nCheckQty,a.nConfirmQty
from tInventoryDtl a, tGoods b
where a.nGoodsID=b.nGoodsID
and a.dInventoryDate = '+quotedstr(DataTimePicker1.date)+
' (这里要空格)and b.sGoodsNO = '+quotedstr(Edit1.Text))
 
adoquery1.SQL.Add('select a.dInventoryDate,b.sGoodsNO,a.sShelfNO,a.nCountQty,a.nCheckQty,a.nConfirmQty
from tInventoryDtl a, tGoods b
where a.nGoodsID=b.nGoodsID
and a.dInventoryDate='''+formatdatetime('yyyy-mm-dd',DataTimePicker1.date)+''''+
' and b.sGoodsNO='''+Edit1.Text+'''')
如果只要日期就这么转化就行了
如果要时间则是'yyyy-mm-dd hh:nn:ss'
 
写错了。
adoquery1.SQL.Add('select a.dInventoryDate,b.sGoodsNO,a.sShelfNO,a.nCountQty,a.nCheckQty,a.nConfirmQty
from tInventoryDtl a, tGoods b
where a.nGoodsID=b.nGoodsID
and a.dInventoryDate = '+quotedstr(DateToStr(DataTimePicker1.date))+
' (这里要空格)and b.sGoodsNO = '+quotedstr(Edit1.Text))
 
帮你顶一下

------------------------------------------------------
http://www.waibaoinfo.com 外包信息网
 
后退
顶部