How to query by RealmInstant?

Example class in kotlin sdk:

class Workout : RealmObject {
/** PROPERTIES */
@PrimaryKey
var id: RealmUUID = RealmUUID.random()
var created: RealmInstant? = RealmInstant.now()
}

Example call (empty result):

val workouts = realm.query(Workout::class, query = “date < $0”, RealmInstant.now()).find()

I did’nt find anything in the documentation how to query Realminstant:. https://www.mongodb.com/docs/realm/realm-query-language/

Anyone knows how to create the query or what datatype i should use instead?

Hi Michael, welcome to the MongoDB community!

It looks like you’re querying against the wrong property name from your class (‘date’ instead of ‘created’). Try updating to this:

val workouts = realm.query(Workout::class, query="created < $0", RealmInstant.now()).find()

Let me know if you’re still having issues.

Thanks!
Cory