POSTGRES declaring variable containing date array in functions I am trying to declare a date array. 

I have tried this:

DECLARE
dateVal DATE[] := ['2018-01-01','2018-02-01'];


I get:

ERROR:  syntax error at or near "["


How do I properly declare it?
You can use ARRAY keyword:

create table tbl (dateval date[]);
insert into tbl values(array ['20180101','20180102'::date]);


Or in a block of code:

do $$
declare 
    dateval date[];
begin
    dateval := array ['20180101','20180102'::date];
end;
$$;


Or cast the expression as an array of dates.

do $$
declare 
    dateval date[];
begin
    dateval := '{2015-4-12, 2015-4-19}'::date[];
end;
$$;


db&lt;>fiddle here