Date addition using Interval

From: "Sumita Biswas" <sbiswas(at)cisco(dot)com>
To: "'Kris Jurka'" <books(at)ejurka(dot)com>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-general(at)postgresql(dot)org>
Subject: Date addition using Interval
Date: 2004-05-03 22:01:25
Message-ID: 023701c4315a$32c55f70$dc656540@amer.cisco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

Does not work. Error as follows:
------------------------------------------------------------------------
--------
WARNING: Error occurred while executing PL/pgSQL function
proc_dailyutilization
WARNING: line 41 at assignment
ERROR: Bad interval external representation 'li_NoOfDays DAYS'
------------------------------------------------------------------------
--------
If I write this way:
ld_FromDateTemp := ld_FromDate + li_NoOfDays ''DAYS''::interval;

Following Error:
------------------------------------------------------------------------
--------
WARNING: Error occurred while executing PL/pgSQL function
proc_dailyutilization
WARNING: line 41 at assignment
ERROR: parser: parse error at or near "'DAYS'" at character 21
------------------------------------------------------------------------
--------

I am sure there is a way of doing it. Can anyone point out where I am
going wrong?

Thanks in Advance.

Regards,
Sumita

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marvin McNett 2004-05-03 22:12:00 insert through function only
Previous Message Manfred Koizar 2004-05-03 21:54:54 Re: 7.4.2 Regression tests: test stats loops indefinately...