vb 问题:求过期商品信息的代码

来源:百度知道 编辑:UC知道 时间:2024/06/16 23:17:39
Private Sub losgoods_Click()
Dim a As Integer
Dim b As Date, c As Date
a = "select 保质期 from 商品表"
b = "select 生产时间 from 商品表"
c = DateAdd("d", a, b)
Sql = "select * from 商品表 where 生产时间> 'c'"
writeMS Sql, Me.MSFlexGrid1

End Sub

成功运行,加你30分

SQL="select * from 商品表 where dateadd(d ,保质期,生产时间)<getdate() "
或者
SQL="select * from 商品表 where datediff(d ,生产时间,getdate())>=保质期 "

第二种方法更好.决可以运行.

Sql = "select * from 商品表 where dateadd('d',保质期,生产时间)<date()"
writeMS Sql, Me.MSFlexGrid1