Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 4th edition of the Campaign Community Lens newsletter is out now!
SOLVED

Passing date to querydef

Avatar

Level 2

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;

}

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

0 Replies

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 1

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>);

 

anilrajbhar_0-1648019642121.png

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

 

anilrajbhar_1-1648019773705.png

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

 

Appreciate your reply.

 

Thanks,

Anil