:
create table x(d timestamp);
insert into x values
('jan 2, 2012'),
('february 4, 2012 12:00'),
('jan 4, 2012 12:00'),
('march 1, 2012'),
('may 3, 2012');
Query:
with input as
(
select
'2012-1-2, 2012-01-04 12:00, 2012-02-04 12:00, 2012-03-04 12:00'::text
as d_input
)
,converted_to_array as
(
select ('{' || d_input || '}')::timestamp[] as d_array
from input
)
select d
from x cross join converted_to_array
where d = any(d_array)
:
D
January, 02 2012 00:00:00-0800
February, 04 2012 12:00:00-0800
January, 04 2012 12:00:00-0800
Live test: http://www.sqlfiddle.com/#!1/43d48/26
IN, :
with input as
(
select
'2012-1-2, 2012-01-04 12:00, 2012-02-04 12:00, 2012-03-04 12:00'::text
as d_input
)
,converted_to_array as
(
select ('{' || d_input || '}')::timestamp[] as d_array
from input
)
select d
from x cross join converted_to_array
where d in (select unnest(d_array))
Live test: http://www.sqlfiddle.com/#!1/43d48/29
:
select d
from x
where d in (select unnest( ('{' || '2012-1-2, 2012-01-04 12:00, 2012-02-04 12:00, 2012-03-04 12:00'::text || '}')::timestamp[] ))
, stackoverflow: -)
Live test: http://www.sqlfiddle.com/#!1/43d48/31