Passing date to querydef | Community
Skip to main content
Level 2
March 28, 2017
Solved

Passing date to querydef

  • March 28, 2017
  • 1 reply
  • 3150 views

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;

}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by vraghav

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

1 reply

vraghav
Adobe Employee
vraghavAdobe EmployeeAccepted solution
Adobe Employee
March 29, 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

March 23, 2022

Hi Vapsy ,

 

Could you please let me know how to perform dateformat function in querydef?

 

<queryDef schema="CSBD:MemberPhoneAudit" operation="select" distinct="true" >
<select>
<node expr="@PrimaryPhoneNumber" label="PrimaryPhoneNumber" />
<node expr="@ApplicationName" label="ApplicationName" />
<node expr="@CallTime" label="CallTime" />
<node expr="@Disposition" label="Disposition"/>
</select>
<where>
<condition expr={"@PrimaryPhoneNumber='" + a +"'"}/>
</where>
</queryDef>);

 

Also its adding 4 hours to my hours. Is it taking Adobe system time?

 

Final output I want is : 2020-07-06 11:53:51

 

Appreciate your reply.

 

Thanks,

Anil