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.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityA 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/
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...