couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Zedeler." <>
Subject Re: Sorting dates in CouchDB
Date Mon, 08 Oct 2012 19:11:23 GMT
On 2012-10-08 11:58, Carl Bourne wrote:
> Aurélien,
>> You can do that, but be aware that you're comparing strings of different lengths.
>> One consequence is that you won't get timestamps from 2012-12-02.
> I just checked some of my data and all of the stored strings are of the same length.
Am I understanding you correctly here? e.g.
> "expire":"2012-10-04T22:19:00+00:00"
> "expire":"2012-10-04T22:19:00+00:00"
> [...]
> "expire":"2012-10-06T00:07:00+00:00"
Auréliens point is that when you use strings, they are sorted 
lexicographically, so

'abc' < 'bbc'

(Because 'a' < 'b'.)

And thus

'2012-10-06' < '2012-10-06T00:07:00+00:00'

(Because '' < 'T00:07:00+00:00' - the empty string always ranks lower 
than any other string.)

So in order to get all data from 2012-10-06, you can either use the end 
key '2012-10-07' or include some letter that you know will serve as a 
safe delimiter, such as 'Z' (my suggestion) - the end key then becomes 



View raw message