仅在sql server中将datetime转换为date

时间:2014-08-09 06:11:45

标签: sql sql-server datetime

我创建了一个列,用日期时间存储我的每日交易,我试图完成最近7天的交易,但它仍然与交易时间分开。 我试图改变日期时间,但无济于事。

SELECT TOP (100) PERCENT 
   SUM(total) AS Total, 
   CONVERT(datetime, DateCreated, 101) AS Expr1
FROM
   dbo.SalesOrderHeader
WHERE        
   (DateCreated >= GETDATE() - 7) AND (DateCreated <= GETDATE())
GROUP BY 
   DateCreated
ORDER BY 
   DateCreated

这是我的结果:

enter image description here

0 个答案:

没有答案