0
(function ($) {
    $(function () {
        $("#datepicker").datepicker({ dateFormat: 'yy-mm-dd' } );
       $("#timepicker").timepicker({
           timeFormat: 'HH:mm:ss'
       });
       $("#datepickerto").datepicker({ dateFormat: 'yy-mm-dd'  });
       $("#timepickerTo").timepicker({
           timeFormat: 'HH:mm:ss'

       });
    });
})(jQuery);

 targetList = list.getByTitle('AppbokningarList');
    var frDate = new Date(result);
    var tDate = new Date(result2);
    var camlQuery = new SP.CamlQuery(),
        collListItem, strViewXml;

    strViewXml = "<View><Query><OrderBy><FieldRef Name='EventDate'/></OrderBy><Where><And><Lt><FieldRef Name='EndDate'/>";
    strViewXml += "<Value Type='DateTime'>" + frDate.toISOString + "</Value></Lt><Gt><FieldRef Name='EventDate'/>";
    strViewXml += "<Value Type='DateTime'>" + tDate.toISOString + "</Value></Gt></And></Where></Query></View>";

    camlQuery.set_viewXml(strViewXml);
    collListItem = targetList.getItems(camlQuery);
    context.load(collListItem);

UPDATE

var result = listItemCustom + "T" + "" + listItemFromTime + ":00" + ":000" + "Z";
    newItem.set_item('EventDate', result);
    var result2 = listItemtoDate + "T" + "" + listItemToTime + ":00" + ":000" + "Z";
    newItem.set_item('EndDate', result2);
6
  • Where are you getting the value of result and result2 from? – Stuart C Nov 18 '14 at 10:25
  • From another function were i display the users input. will update @scmc – Batistuta Nov 18 '14 at 10:26
  • Does the format your setting the datetime to match what is set under the regional settings for the SharePoint Site? Site Actions > Site Administration > Regional Settings – Stuart C Nov 18 '14 at 10:31
  • No because in the view time is right and also in the debugger, but in the list it gets +1, its confuesed by winter and summertime – Batistuta Nov 18 '14 at 10:34
  • Check the regional/date settings on your server. In the past, we have noticed that if these are different to what's set in SharePoint you can see some strange behavior. – Stuart C Nov 18 '14 at 10:38
0

Run into something similar a few days ago. I believe it has to do with the date format. I was using German(Germany) locale (Site Setting > Regional Settings), thus my dates were of format dd.mm.yyyy. When trying to do calculations with the day NaN (not a number) was being returned. I tried the English (United Kingdom) Format, dd/mm/yyyy, which returned a result but wrong value. Finally I tried the English (United States), mm/dd/yyyy which returned the correct results. Apparently JS has trouble recognizing date strings split by '.' and reads them in the US format order (month > date > year). I suggest changing locale in your Regional Settings (Time Zone does not have to Change) and see if you get the correct results. I believe the datejs library helps hundle and calculate in all date formats, but I didn't use it so I can not help you with that. (wanted to post this as a comment, but it seems I don't have enough reputation to do so yet :) )

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.