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.

| improve this question | | | | |
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/

| improve this answer | | | | |
  • 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. – Kenneth Van Coppenolle Apr 4 '16 at 9:37
  • Link reference here is broken. – Paul T. Feb 19 '17 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...

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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