Skip to main content
1-Visitor
June 9, 2017
Question

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

  • June 9, 2017
  • 2 replies
  • 2458 views

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

    2 replies

    20-Turquoise
    June 9, 2017

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

    akesana1-VisitorAuthor
    1-Visitor
    June 11, 2017

    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

    5-Regular Member
    June 12, 2017

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