user1179567
user1179567

Reputation: 193

RethinkDB Time Query Issue

I'm trying to run what seems like it should be a pretty basic query from the Data Explorer:

r.db("test").table("test_table").group(r.row('date').dayOfWeek())

where date is a TIME obj

I'm getting the following error:

e: Error in time logic: Year is out of valid range: 1400..10000 in: r.db("test").table("test_table").group(r.row("date").dayOfWeek())

Any date/time function I try and use on the "date" field gives me the same error.

Here is an example of objects I have stored in the table:

{"iat":{"$reql_type$":"TIME","epoch_time":1467895446.724,"timezone":"-06:00"},"id":"0212197a-4891-4475-a30d-ebebc34ba0e4","minutes":152.78329467773438,"date":{"$reql_type$":"TIME","epoch_time":1467784800,"timezone":"-06:00"}}

Upvotes: 1

Views: 78

Answers (1)

Etienne Laurin
Etienne Laurin

Reputation: 7184

One of your documents has a year that is not supported by dayOfWeek. The RethinkDB documentation has this to say:

Most date operations are only defined on years in the range [1400, 10000] (but note that times in the year 10000 cannot be printed as ISO 8601 dates).

You can probably find the offending documents using a query like this:

var limit = r.ISO8601("1400-01-01T00:00Z")
r.table('test_table').filter(r.row('iat').lt(limit).or(r.row('date').lt(limit))

Upvotes: 0

Related Questions