Filtering data based on datetime

Is there an option of filtering data using views based on current datetime
For ex. I've many JSON Document each of these document contains a key:value as

I would like to filter those documents whose Starttime is less than current time. Is there a way I can achieve this using view.


2 Answers

« Back to question.


Suppose you have a document like this one:

  "type": "product",
  "date": "2013-08-25T13:41:13.163+01:00"

If you want to do some queries on the date, you need to create a view to index the date, and use a compound key:

function (doc, meta) {
  emit(  dateToArray(;

This will generate an index based on the date that is like the following:


So if you want to get all the document id where the date is "before" August 25 , you have do to this query"



« Back to question.

Couchbase has a great builtin datetime into array function for the mapper

from here you can put the key into start and end range in your view query.