I am trying to find string representation of tstzrange[]
type (array of timestamp ranges):
select '{[2014-01-01,2015-01-01]}'::tstzrange[];
select '{''[2014-01-01,2015-01-01]''}'::tstzrange[];
select '{[''2014-01-01'',''2015-01-01'']}'::tstzrange[];
But each of queries above throws malformed range literal
error.
I know that I can use array[tstzrange('2014-01-01','2015-01-01','[]')]
but what I need is a string representation.
Best Answer
The thing is that here you have to combine two literals:
'{}'
for the array and'[...,...]'
for the range type.In all these cases, the easiest is just getting back the output from the system itself:
Now you simply wrap this into quotes, and there you are.
There is, however, a simpler way, which usually works: just double-quote the inner literal. See:
Note that the output is the same as above.