我被指派创建一个警告,如果今天是项目的专属,那么警报将被发送给团队。
我正在尝试检查如何过滤代码的where子句:
SELECT dbo.salesorder.customerid,
dbo.salesorder.entrydate,
dbo.salesorder.salesorderno,
dbo.salesorderdetails.itemno,
dbo.salesorder.usercreated,
dbo.salesorder.duedate
from dbo.salesorder
inner JOIN dbo.salesorderdetails
ON dbo.salesorder.salesorderid = dbo.salesorderdetails.salesorderid
where (dbo.salesorder.customerid = 238)
如果今天是5月4日,我只是在报告中显示以下突出显示的销售订单。
答案 0 :(得分:1)
将getdate()转换为日期并与duedate进行比较
where (dbo.salesorder.customerid = 238)
and dbo.salesorder.duedate = convert(date, getdate())
答案 1 :(得分:1)
SELECT dbo.salesorder.customerid,
dbo.salesorder.entrydate,
dbo.salesorder.salesorderno,
dbo.salesorderdetails.itemno,
dbo.salesorder.usercreated,
dbo.salesorder.duedate
from dbo.salesorder
inner JOIN dbo.salesorderdetails
ON dbo.salesorder.salesorderid = dbo.salesorderdetails.salesorderid
where dbo.salesorder.duedate = CAST(GETDATE() AS DATE) --or CAST(CURRENT_TIMESTAMP AS DATE)
and dbo.salesorder.customerid = 238