Share via

Internal Query Processor Error: The query processor could not produce a query plan

David Kjendle 20 Reputation points
2025-01-08T18:50:30.4233333+00:00

Getting this error when adding time zones to original query

SELECT YEAR((CAST (log.LogTime AS DateTime) AT TIME ZONE {0} AT TIME ZONE {1})),{2},LPAD(MONTH((CAST (log.LogTime AS DateTime) AT TIME ZONE {3} AT TIME ZONE {4})), 2, {5})) AS Month

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Erland Sommarskog 134.1K Reputation points MVP Volunteer Moderator
2025-01-08T21:07:43.9066667+00:00

I was not able to repeat it with a single select from a table with a datetime column.

But it seems that you want to reduce the timestamp to year and month on the format YYYY-MM. A simple way to do that is

convert(char(7), LogTime, 121)

Try that and see what happens. If nothing else, the code will be slender.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

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