1

What is the difference between CAML Offset and OffsetDays?

I'm familiar with Offset and I'm using it and it is working as i expect. today I've read an article that use the OffsetDays, but there is no description for this proprietary on MSDN.

2 Answers 2

2

A Offset and OffsetDays are same.

See comments, OffsetDays is the correct one to use

Microsoft as always failed to document this.

This link no longer exists:
http://techmotley.com/2012/01/27/correct-offset-for-today-in-caml-queries/

2
  • 1
    Just a word of caution: using CAML queries in PowerShell, I have just run into an issue where Offset was ignored (unfortunately it also didn't throw an error so it went under the radar for a little while). Changing it to OffsetDays the query returned the correct results. So Offset and OffsetDays are apparently not ALWAYS the same. This was on SP2013 on-premise. Apr 4, 2016 at 9:37
  • Link reference here is broken.
    – Paul T.
    Feb 19, 2017 at 14:50
4

Scenario 1 : If you are checking for the items having "Due Date" field value as "Today", then this would be the query for you:

<Where>
    <Eq>
        <FieldRef Name="DueDate" />
        <Value Type="DateTime">
            <Today/>
        </Value>
    </Eq>
</Where>

Scenario 2 : what if you want something dynamic? Ex. If you want to get the items, having "Due Date" 5 days before Today. For this you can't give a static day, because "Today" changes daily. Option is "OffsetDays". The Query goes like this :

 <Where>
     <Eq>
         <FieldRef Name="DueDate" />
         <Value Type="DateTime">
             <Today OffsetDays="-5" />  ----------> for future dates the value should be positive.
         </Value>
     </Eq>
 </Where>

In many documents they have mentioned Offset instead of "OffsetDays"... better be careful while checking...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.