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
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,310 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 115.5K Reputation points MVP
    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.


0 additional answers

Sort by: Most helpful

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.