2

I have startdate as 18/12/2014 and enddate as 22/12/2014 But when trying to use the below query it doesn't work

 <Where>
  <Or>
     <Geq>
        <FieldRef Name='StartDate' />
        <Value Type='DateTime'>
           <Today Offset='7' />
        </Value>
     </Geq>
     <Leq>
        <FieldRef Name='EndDate' />
        <Value Type='DateTime'>
           <Today Offset='-7' />
        </Value>
     </Leq>
  </Or>

Thanks in advance. I did wrap a <Query></Query> around it. Thanks I Advance

3
  • check this sharepoint.stackexchange.com/questions/90203/…
    – Waqas Sarwar MVP
    Dec 18, 2014 at 5:11
  • Thanks for that but i still need the OffSet.How can i deduct the days from Today using either of the methods
    – naijacoder
    Dec 18, 2014 at 5:29
  • I saw this on SPServices forum as well. The correct attribute to use is OffsetDays - regardless of what the MS docs have. To me, it looks like the values of Geq and Leq are reversed. The above is trying to get all items where the start date is greater than 7 days from today --OR-- the end date is Less than 7 days ago. Is that what you really want?
    – Paul T.
    Dec 19, 2014 at 18:13

2 Answers 2

4

Have you tried using 'OffsetDays' instead of 'Offset'?

<Today OffsetDays='-7'/>
6
  • How does OffsetDays differ from Offset? MSDN states that the only attribute for <Today> is Offset.
    – wjervis
    Dec 18, 2014 at 15:20
  • Maybe the documentation is wrong. I can't find any proof of that - but this site suggests that at one time there were some comments regarding it on MSDN. TechMotley
    – Will
    Dec 18, 2014 at 15:41
  • Very peculiar. Btw, you might want to redo that link, the closing > got added to the end of the url.
    – wjervis
    Dec 18, 2014 at 15:43
  • Fixed the link, thanks for the heads up - sorry about that.
    – Will
    Dec 18, 2014 at 15:46
  • Hi wjeris, Im using this on a sharepoint 2010 so is it 'OffsetDays' or 'Offset'?
    – naijacoder
    Dec 18, 2014 at 23:15
1

Have you tried building the CAML Query like this?

This gives you a date offset of 7 days.

<Where>
  <Or>
     <Geq>
        <FieldRef Name='Created' />
        <Value Type='DateTime'>[18/12/2014 08:16:33 AM+7Day(s)]</Value>
     </Geq>
     <Leq>
        <FieldRef Name='Created' />
        <Value Type='DateTime'>[18/12/2014 08:16:57 AM-7Day(s)]</Value>
     </Leq>
  </Or>
</Where>
2
  • Thanks Vince Im doing this via script and trying to find a way i can deduct the time before using it as i need it in ISO format
    – naijacoder
    Dec 18, 2014 at 22:58
  • Can you post the script your using? Dec 19, 2014 at 5:49

Your Answer

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

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