Passing date to querydef

MeMonty

28-03-2017

Hi,

I have written a function (as shown below) to fetch all the deliveries on a day. For the same I am passing two dates today & tomorrow (with time part of 00:00:00). But I am getting an error

Error while executing the method 'ExecuteQuery' of service 'xtk:queryDef'.

Unable to parse expression '@created >= Tue Mar 28 2017 09:42:30 GMT+0000 (UTC)'.

Element 'Tue' unknown (see definition of schema 'Deliveries (nms:delivery)').

//  ==========   function getDeliveries()   ==========

function getDeliveries(paramDate1, paramDate2)

{

  var deliveriesArray = new Array();

  logInfo("BEGIN (function) ... getDeliveries()");

  logInfo("Type of Parameter-1 ... : " + typeof paramDate1 + "      Type of Parameter-2 ... : " + typeof paramDate2);

  logInfo("Parameter-1 ... : " + paramDate1.toString() + "      Parameter-2 ... : " + paramDate2.toString());

  var query = xtk.queryDef.create(

    <queryDef schema="nms:delivery" operation="select">

      <select>

        <node expr="@id"/>

      </select>

      <where>

        <condition expr={"@created >= " + Date(paramDate1)}/>

        <condition booleanOperator="AND" expr={"@created < " + Date(paramDate2)}/>

      </where>

    </queryDef>);

    var res = query.ExecuteQuery();

    var i = 0;

    for each (var delivery in res.delivery)

    {

      deliveriesArray.push(delivery.@id);

      i++;

    }

  var arrLen = deliveriesArray.length;

  logInfo("Number of Deliveries ... : " + arrLen);

  logInfo("END (function) ... getDeliveries()");

  return deliveriesArray;

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Vapsy

Employee

29-03-2017

Hi Mahantesh,

QueryDef takes data parameters in this format

expr="@created &gt;= #2017-03-26 22:00:00.000Z#"

So the params you are passing has to be in this format.

Regards,

Vipul