cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to get last 10 days data into my info table from stream?

akesana
1-Newbie

How to get last 10 days data into my info table from stream?

Hi,

We have a stream we are filtering data based one column name , Now we want check date also and get only last 10 days data.

Please find below syntax

// dateValue:DATETIME

var dateValue = new Date();

// dateAddDays(dateValue:DATETIME,amount:NUMBER):STRING

var datetime = dateAddDays(dateValue, -10);

var query =

{

  "filters": {

      "type":"AND",

      "filters": [

          {

  "type": "LIKE",

  "fieldName": "source",

  "value": "*anil*"

   },

          {

              "type":"GT",

          "fieldName":"timestamp",

          "value":datetime    // This is sting type but we want to validate date type how to do this check?

          }          

      ]

  }

But it is not working as expected, could any one correct my mistake in the above code?

Regards

Anil Kesana

3 REPLIES 3
posipova
20-Turquoise
(To:akesana)

You can actually utilize the snippet QueryPropertyHistory. You may set start date as current through javascript and then calculate minus 10 days (keep in mind the dates are in milliseconds):

Hi Polina,

We are getting data from stream not from value stream, I could not get stream data using querypropertiyhistory.

Other hand we want to check source column also while getting data from stream.

Could you please check and let us know what would be the right way to achieve that?

Regards,

Anil Kesana

ankigupta
5-Regular Member
(To:akesana)

Hi Anil Kesana​,

You can use QueryStreamEntriesWithData Service for the Streams and pass the parameters as per your requirement.

var params = {

    oldestFirst: undefined /* BOOLEAN */,

    maxItems: undefined /* NUMBER */,

    sourceTags: undefined /* TAGS */,

    endDate: undefined /* DATETIME */,

    query: undefined /* QUERY */,

    source: undefined /* STRING */,

    startDate: undefined /* DATETIME */,

    tags: undefined /* TAGS */

};

// result: INFOTABLE dataShape: "undefined"

var result = me.QueryStreamEntriesWithData(params);

Top Tags