我创建了一个列,用日期时间存储我的每日交易,我试图完成最近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
这是我的结果: