CAML query not working with dates no idea why

Dec 18, 2014 at 5:26 AM
Hi Guys,
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
Coordinator
Dec 18, 2014 at 11:48 AM
Are you trying to get items that are currently happening? e.g., where now is between StartDate and EndDate?

M.
Dec 18, 2014 at 3:50 PM
Try changing "Offset" to "OffsetDays" and see if it works for you.

Geoff
Dec 19, 2014 at 12:29 AM
Yes Marc i'm trying to do exactly what you wrote but Offset isnt working for me. I also tried OffsetDays though but no luck.
Any ideas.
How else can i get the date in js and deduct it myself and pass it through
Dec 19, 2014 at 3:32 AM
Im trying to do this.
var date = new Date();
var r = date.toISOString();
r gives me the ISOdate but how can i deduct days from this date?
Dec 19, 2014 at 4:39 AM
ended up using OffsetDays after outputing a date like this below arg!!!! It didnt work before

incase it helps anyone:):
var plusdays =7;
var minusdays =-7;
 
//alert(addDay(dateMsg,plusdays));
//alert(addDay(dateMsg,minusdays));

var isodatep = addDay(dateMsg,plusdays)
var isodatem = addDay(dateMsg,minusdays)

//alert(isodatep.toISOString()); 
//alert(isodatem.toISOString()); 

function addDay(date,plusdays) {
    var decomposed = date.split("/"),
        moreDay = new Date(decomposed[2], decomposed[1] - 1, decomposed[0]);
    moreDay.setDate(moreDay.getDate() + plusdays);
    //alert(moreDay);
    return moreDay;
}


function minusDay(date,minusdays) {
    var decomposed = date.split("/"),
        moreDay = new Date(decomposed[2], decomposed[1] - 1, decomposed[0]);
    moreDay.setDate(moreDay.getDate() - minusdays);
    //alert(moreDay);
    return moreDay;
}