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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to query infotable to check given column is between specified date values?

nbhagtani
2-Guest

How to query infotable to check given column is between specified date values?

I have got infotable and i need to check that any column(having date value) is between specified start and end date. I tried one sample but it gives me error :

" Wrapped org.json.JSONException: JSONObject["type"] not found. Cause: JSONObject["type"] not found."

below is the code i tried:

var query = {

   "filters": {

          //type: "OR",

          "filters": [

            {

            "fieldName": "Temperature",

            "type": "BETWEEN",

            "from": startDate,

            "to": endDate

          },

          {

            "fieldName": "Humidity",

            "type": "BETWEEN",

            "from": startDate,

            "to": endDate

          }

        

       ]

   }

};

var recordsToDisplay = Resources['InfoTableFunctions'].Query(

    {      

        query : query,     

        t : requiredRows   

    } );

Please help me where i am going wrong.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Nisha,

I think you have two undesired slashes // in front of type: "OR".

Also type should be "type".

And one last thing, inner "filters" parameter content it's an array, then you should set it's conent with [ ] instead of { }.

You should have something like this:

var query = {

  "filters": {

    "type": "OR",

    "filters": [

      {

        "fieldName": "Temperature",

        "type": "BETWEEN",

        "from": startDate,

        "to": endDate

      },

      {

        "fieldName": "Humidity",

        "type": "BETWEEN",

        "from": startDate,

        "to": endDate

      }

    ]

  }

};

View solution in original post

3 REPLIES 3
CRArko
17-Peridot
(To:nbhagtani)

Hello, Nisha.

The closest I've been able to find to what you're asking for is in:

Query Infotable

It talks about using the Query() InfoTableFunction in the Snippets tab to make the query on the InfoTable. Let me try this and see if I can find what's missing.

-- Craig A.

Hi Nisha,

I think you have two undesired slashes // in front of type: "OR".

Also type should be "type".

And one last thing, inner "filters" parameter content it's an array, then you should set it's conent with [ ] instead of { }.

You should have something like this:

var query = {

  "filters": {

    "type": "OR",

    "filters": [

      {

        "fieldName": "Temperature",

        "type": "BETWEEN",

        "from": startDate,

        "to": endDate

      },

      {

        "fieldName": "Humidity",

        "type": "BETWEEN",

        "from": startDate,

        "to": endDate

      }

    ]

  }

};

Thanks Carles it worked.

Top Tags