Skip to main content
1-Visitor
July 12, 2017
Solved

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

  • July 12, 2017
  • 3 replies
  • 5456 views

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.

Best answer by CarlesColl

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

      }

    ]

  }

};

3 replies

5-Regular Member
July 12, 2017

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.

1-Visitor
July 13, 2017

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

      }

    ]

  }

};

nbhagtani1-VisitorAuthor
1-Visitor
July 17, 2017

Thanks Carles it worked.