Unresolved reference to object error then trying to use DATE_BUCKET function

Borisov, Maksim 0 Reputation points
2023-01-12T13:09:45.8133333+00:00

Hi, I'm using VS 2022 SQL server database project with target platform to SQL server 2022 (Compatibility mode 160). I tried to use new DATE_BUCKET function in the view:

CREATE VIEW dbo.Weeks
AS
SELECT DATE_BUCKET(WEEK, 1, GETDATE()) AS WeekStart

But got the error:

Error: SQL71005: The reference to the column WEEK could not be resolved.

The same code works fine in the MSS Management studio. I'm sure that I selected correct Compatibility mode for the project, because I can use also new GENERATE_SERIES function without errors.

Please, help me how to solve it or maybe I something missing?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
41,401 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.