我在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)
如何解决这个问题?感谢
答案 0 :(得分: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