我正在尝试引入当月(5 / 1-5 / 31)的数据,并在以后的每个月都这样做。在使用以下代码的地方,它不起作用。如果我将其更改为> =,它将带来2016年以来的所有数据。有什么想法我做错了吗?
WHERE [20200512 Daily Deposits].[Date] = MONTH(getdate()) and [20200512 Daily Deposits].[Date] = YEAR(getdate())
假设您正在使用SQL Server:
where [20200512 Daily Deposits].[Date] >= datefromparts(year(getdate(), month(getdate(), 1) and
[20200512 Daily Deposits].[Date] < dateadd(month, 1, datefromparts(year(getdate(), month(getdate(), 1))