Re: Date addition using Interval - Mailing list pgsql-general

From Richard Huxton
Subject Re: Date addition using Interval
Date
Msg-id 4099139F.20804@archonet.com
Whole thread Raw
In response to Date addition using Interval  ("Sumita Biswas" <sbiswas@cisco.com>)
Responses Re: Date addition using Interval  ("Sumita Biswas" <sbiswas@cisco.com>)
Function with RETURN TYPE RECORD Called From JAVA  ("Sumita Biswas" <sbiswas@cisco.com>)
List pgsql-general
Sumita Biswas wrote:
> Hi Experts,
>
> I try to write the following in my Function and it works:
>
> ld_FromDateTemp := ld_FromDate + ''5 DAYS''::interval;
>
> But when I have to pass a parameter in the NUMBER of days(instead of 5)
> like 'li_NoOfDays'
>
> ld_FromDateTemp := ld_FromDate +  ''li_NoOfDays DAYS''::interval;

You want ... + (li_NoOfDays || '' DAYS'')::interval;

plpgsql doesn't interpolate variables like perl/php do.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Alexander Cohen
Date:
Subject: list types
Next
From: Adam Ruth
Date:
Subject: Re: PERFORM function in Plpgsql