0

I want to filter data from the ledger between two dates , start date and end date.How can this be done using rich queries in couch db

{
            "date": {
                "$in": [startdate, enddate]
            }

}

I know this will give only those data which has dates as start date and end date.How to do this?

aeshna Kashyap
  • 135
  • 2
  • 12
  • Possible duplicate of [Couch DB query to fetch the records greater than a particular date](https://stackoverflow.com/questions/53388100/couch-db-query-to-fetch-the-records-greater-than-a-particular-date) – Jonathan Hall Aug 09 '19 at 14:47

1 Answers1

1

You can do this by this way.

{"selector": 
    {"date":
       {"$gte": "startDate",
        "$lte": "endDate"
       }
    }
}

But for getting the exact result you should store the date as a timestamp and pass the from date and to date as a timestamp in the chaincode as arguments.For querying in the chaincode you can convert your date format to timestamp at your backend.

Anju boura
  • 35
  • 8