I am converting some of the queries I have from CAML to SharePoint search SQL and ran across an issue when trying to compare my Date metadata fields to "Today."
Specifically, I have the following part of a CAML query that uses :
<Leq><FieldRef Name="Article_x0020_Publish_x0020_Date"/><Value Type="DateTime"><Today /></Value></Leq>
When attempting to convert that into SharePoint search SQL I was following the microsoft documentation; specifically the DATEADD documentation. I came up with this:
SELECT Title, ArticlePublishDate FROM SCOPE() WHERE "SCOPE" = 'Articles' AND ArticlePublishDate <=DATEADD (DAY, 0, GETGMTDATE())
However, when I use this query I get the following exception message:
Name cannot begin with the '=' character, hexadecimal value 0x3D. Line 1, position 296.
As an added twist, if you change the '<=' operator to a '>=' operator then it accepts the query:
SELECT Title, ArticlePublishDate FROM SCOPE() WHERE "SCOPE" = 'Articles' AND ArticlePublishDate >=DATEADD (DAY, 0, GETGMTDATE())
Is this a case of the Monday's? Is Microsoft messing with me? Or is this really broken...