I'm using the below as a rolling date filter, but SQL thinks i'm referencing the column in my table that shares the same name "mm", when I want to use it as a function.Is there a way around this?
This is the end result i'm looking for:
BETWEEN DATEADD(m, DATEDIFF(mm, 0, GETDATE()) - 12, 0) AND DATEADD(m, DATEDIF(mm, 0, GETDATE()) - 1, 0)
SQL changes my filter to this due to my table named "DateFile":
BETWEEN DATEADD(m, DATEDIFF(DateFile.mm, 0, GETDATE()) - 12, 0) AND DATEADD(m, DATEDIFF(DateFile.mm, 0, GETDATE()) - 1, 0)
We are in process of upgrading to a new server which has brought this issue to light. Unfortunately we have several hundred views using the table "DateFile", so the simple fix of changing the column name isn't a great option. I do have a work around, but was hoping for something as simple as two [brackets]. Thanks in advance!