Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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
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
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);