Start a new topic

Nativescript/Kinvey - querying data between two calendar dates


We have a requirement to get the data entered between two calendar dates. We are using Nativescript/Javascript and Kinvey as backend. Can someone share some examples of Date Query operations?

Hello Raghavendra,

I am not familiar with NativeScript but I would still like to provide you with a suggestion. I will also ask my colleague to check this because he has good knowledge of NativeScript.

You can query the records in a specific timeframe using "$gte" (greater than or equal to) and "$lte" (less than or equal to) on  '_kmd.lmt' values ("kmd" means Kinvey Meta Data and "lmt" means Last  Modified Time).

Let's say, you have following timestamps and you want to get all the records modified between those 2 timestamps:

2018-02-19T06:42:36.862Z - Mon, 19 Feb 2018 06:42:36 +00:00

2018-07-13T04:28:38.479Z - Fri, 13 Jul 2018 04:28:38 +00:00

Now you want to get all the records modified between above 2 timestamps i.e. modified after 19th Feb and before 13th July. Your query in the Kinvey API console should be:





Thanks Pranav!!

It would be nice to understand how to write this query in Nativescript, as the API's are different.

Hi Raghavendra,

I assume you are using Kinvey Nativescript SDK. Then you may use the operators described here -

So for the dates the query would look like this:

const query = new Kinvey.Query();
query.greaterThanOrEqualTo('_kmd.lmt', "2018-02-19").lessThanOrEqualTo('_kmd.lmt', "2018-07-13");

Let me know if this has helped.

Martin Apostolov

Thanks Martin!!!

Appreciate your help!!

no, this will give empty entity.... _kmd.lmt contains both date and time. so the above mentioned query will not work.

one thing i want to say is. querying between dates is a very basic thing which must be included in every database documentation. but in kinvey doc i found nothing. so this issue is the major drawback of kinvey. and its very difficult to workaround and bring some solution for this especially for beginners.

thank you kinvey.....

Hi megahard technologies,

Dates in Kinvey are stored as ISO string format (ISO 8601). ISO 8601 was designed for lexicographical sort. As such the ISO8601 string representation can be sorted like any other string, and this will give the expected order even without including the time data:

'2018-02-19' < '2018-07-13T08:00:00Z' === true

Are you seeing an issue with the above at your end? 

Are you using Business Logic and collectionAccess module?

Let me know if this has helped.

Login or Signup to post a comment