0

Sharepoint hosted app where saving and reading data from sharepoint list.

Getting time to Datetimepicker and convert it to current timezone:

    var Time1 = $('#TextBox_Startdate').val();
    var Clock1 = $('#clock1').find(":selected").text();
    var Time2 = $('#TextBox_Enddate').val();
    var Clock2 = $('#clock2').find(":selected").text();

    var convertDate1 = new Date(Time1);
    var zone1 = convertDate1.getTimezoneOffset() * -1 / 60;
    var convertDate2 = new Date(Time2);
    var zone2 = convertDate2.getTimezoneOffset() * -1 / 60;

    var datetime1 = Time1 + "T" + Clock1 + ":00+" + "0" + zone1;
    var datetime2 = Time2 + "T" + Clock2 + ":00+" + "0" + zone2;

Camlquery:

    "<And>" +
    "<Leq>" +
    "<FieldRef Name='datetimedata1' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + datetime1 + "</Value>" +
    "</Leq>" +
    "<Gt>" +
    "<FieldRef Name='datetimedata2' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + datetime2 + "</Value>" +
    "</Gt>" +
    "</And>" +

Values to try to save:

datetime1 value = 2019-01-18T12:00:00+2

datetime2 value = 2019-01-18T13:00:00+2

Values already in list:

datetimedata1 value = 2019-01-18T11:00:00+2

datetimedata2 value = 2019-01-18T12:00:00+2

Problem: I don't want make doublebooking. Still query results "there is previously saved value!"

New starting time is -> datetime1 value = 2019-01-18T12:00:00+2 And already value in list ->datetimedata2 value = 2019-01-18T12:00:00+2

Could be same on lower.

I thougt they were the same but not. (seconds ?).

  • NO you have time 12:00:00 so there are the same seconds. Problem is in the CamlQuery, cause you have here operand AND and if you use same date, you need OR, cause its LEQ or GEQ and this will return you a value. Can you try it if it's fix your problem? – Zdeněk Vinduška Jan 18 at 11:55
0

I just solved the problem. Must be two datetime variant: one for query and second for inserting data to list.

Inserting data:

var Time1 = $('#TextBox_Startdate').val();
var Clock1 = $('#clock1').find(":selected").text();

var convertDate1 = new Date(Time1);
var zone1 = convertDate1.getTimezoneOffset() * -1 / 60;

var datetime1forinsert = Time1 + "T" + Clock1 + ":00+" + "0" + zone1;

Query:

var Time1 = $('#TextBox_Startdate').val();
var Clock1 = $('#clock1').find(":selected").text();

var datetime1forquery= Time1 + "T" + Clock1 + ":00";

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.