interval +variable
interval +variable
От:
"Fatih Cerit" <fatih@intersan.com.tr>
Дата:
Dear all Is there anyone at there who knows howto use dateadd in pgsql. I have a problem in my function that is like this ; Select into futuredate now() + interval '30 days'; <- this is ok but how can I use a variable intead of '30 days' :( Thanks
Re: interval +variable
От:
Michael Fuhr <mike@fuhr.org>
Дата:
On Wed, Mar 09, 2005 at 10:58:05AM +0200, Fatih Cerit wrote: > Is there anyone at there who knows howto use dateadd in pgsql. I have a > problem in my function that is like this ; > > Select into futuredate now() + interval '30 days'; <- this is ok > but how can I use a variable intead of '30 days' :( Are you looking for something like this? ndays := 30; SELECT INTO futuredate now() + ndays * interval'1 day'; -- Michael Fuhr http://www.fuhr.org/~mfuhr/
Re: interval +variable
От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Wed, Mar 09, 2005 at 10:58:05 +0200, Fatih Cerit wrote: > Dear all > > Is there anyone at there who knows howto use dateadd in pgsql. I have a > problem in my function that is like this ; > > Select into futuredate now() + interval '30 days'; <- this is ok > but how can I use a variable intead of '30 days' :( A better solution may to be to use the date type instead of the timestamp type. Then you can just add an integer number to the date. You also don't have to worry about daylight savings time changes.
Re: interval +variable
От:
"ALÝ ÇELÝK" <ali@verus.com.tr>
Дата:
+ '1 days'::interval ""Fatih Cerit"" , haber iletisinde �unlar� yazd�:008a01c52486$1c1c9520$bb41ccd5@cerit... > Dear all > > Is there anyone at there who knows howto use dateadd in pgsql. I have a > problem in my function that is like this ; > > Select into futuredate now() + interval '30 days'; <- this is ok > but how can I use a variable intead of '30 days' :( > > Thanks > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match >