Guesswork (the rest of the function definition is missing).
This would work in PL/pgSQL (which are using behind the curtains):
window_end_date := window_start_date + interval duration;
Or:
window_end_date := window_start_date + duration::interval;
Cast the
text
value tointerval
to make it work. But it would be better to declare the variableduration
asinterval
to begin with (maybe that is the case, then drop the cast - information missing).The assignment operator in plpgsql is
:=
, not=
.The result is a
timestamp
, not adate
. But it will be coerced todate
in your example.