0

我从 Sale 表中有以下查询,并希望按短日期对其进行过滤。

Dim query = From c In db.Sale Where c.TRAN_DATE=TranDateParam
            Group By c.TRAN_DATE Into Total_Payment = Sum(c.PAYMENT),Discount_Amount = Sum(c.DISCOUNT) _
            Select Total_Payment, Discount_Amount, TRAN_DATE

-我的 c.TRAN_DATE 值包括时间。示例:“2013-05-01 10:09:49.107”
-我的 TranDateParam 值是短日期格式。示例:“2013-05-01”

因此我无法比较 c.TRAN_DATE=TranDateParam。我尝试了许多方法将 c.TRAN_DATE 隐蔽到短日期但不成功。

我尝试以下方法但失败了:

c.Tran_Date.ToString("dd-MM-yyyy")
c.Tran_Date.Value.ToShortDateString()
CDATE(c.Tran_Date)

我该如何解决这个问题?谢谢

4

1 回答 1

0

问题已解决。我只是将我的查询更改如下:

Dim query = From c In db.Sale Where c.TRAN_DATE= CDate(TranDateParam) _
            Group By c.TRAN_DATE Into Total_Payment = Sum(c.PAYMENT),Discount_Amount = Sum(c.DISCOUNT) _
            Select Total_Payment, Discount_Amount, TRAN_DATE
于 2013-06-01T06:30:29.570 回答