postgresql - ERROR: invalid input syntax for type timestamp: "end_time" -
new postgresql , newer jsonb. trying filter array of objects:
[{"event_slug":"test_1","start_time":"2014-10-08","end_time":"2014-10-12"}, {"event_slug":"test_2","start_time":"2013-06-24","end_time":"2013-07-02"}, {"event_slug":"test_3","start_time":"2014-03-26","end_time":"2014-03-30"}]
my query:
select l.* locations l , jsonb_array_elements(l.events) e l.events @> '{"event_slug":"test_1"}' , e->>'end_time'::timestamp >= '2014-10-30 14:04:06 -0400'::timestamptz;
i error:
error: invalid input syntax type timestamp: "end_time" line 5: , e->>'end_time'::timestamp >= '2014-10-30 14:04:06 -04... ^
this operator precedence issue: ::
binds more tightly ->>
does. need parentheses.
e->>'end_time'::timestamp
becomes
(e->>'end_time')::timestamp
Comments
Post a Comment