Select Interval in plpgsql

Поиск
Список
Период
Сортировка
Искать
От
Derrick Betts
Тема
Select Interval in plpgsql
Дата
Msg-id
017901c52e8e$a5408570$0200a8c0@main
Список
Дерево обсуждения
Select Interval in plpgsql "Derrick Betts" <derrick@grifflink.com>
Re: Select Interval in plpgsql John DeSoi <desoi@pgedit.com>
I can't seem to figure out how to accomplish this task in a plpgsql function:
 
I have a timestamp variable 'apt_time' and a varchar variable 'time_offset'.  The time_offset variable usually looks like this: '-2 hours'.  What I want to do is add the time_offset to the timestamp.  So I have tried:
 
SELECT apt_time + interval time_offset INTO Adjusted_Time; 
 
Where Adjusted_Time is the variable to store the result.
 
But I keep getting errors.  I'm not sure where the problem is, as I obviously have not set up the field or variable types properly, or have structured the SELECT improperly.
 
This statement works just fine:
 
SELECT apt_time + interval '-2 hours' INTO Adjusted_Time; 
 
but when I try to use a variable with the interval, I can't get it to work.
 
Any help would be appreciated.
 
Thanks,
Derrick
 
 
В списке pgsql-novice по дате отправления
От: Morgan Kita
Дата:
Сообщение: Advice on custom data types
От: John DeSoi
Дата:
Сообщение: Re: Select Interval in plpgsql
FAQ