我想在哪里“ ReceiptDate =?应该是当前系统日期...。我想写一下如何在SQL中获取当前系统日期。

时间:2018-08-31 07:46:26

标签: sql vb.net ms-access

SELECT        
    SUM(ReceiptDetails.ItemSellPrice * ReceiptDetails.ItemQty) AS TotalSalesForToday
FROM            
    (ReceiptDetails 
INNER JOIN
    Receipt ON ReceiptDetails.ReceiptID = Receipt.ReceiptID)
WHERE
    (Receipt.ReceiptDate =?)

1 个答案:

答案 0 :(得分:0)

使用DATE()函数。

如果该值确实是日期,则可以进行直接比较:

WHERE Receipt.ReceiptDate = DATE()

如果ReceiptDate也有时间成分,则:

WHERE Receipt.ReceiptDate >= DATE() AND
      Receipt.ReceiptDate < DATEADD("day, 1, DATE())