Casting varchar to interval

Started by Chrisover 23 years ago1 messagesgeneral
Jump to latest
#1Chris
pgsql@cmulcahy.com

Greetings:

I'm trying to store a timeout value into a settings table:
create table settings(
stattr varchar(25),
stvalue varchar(25));
insert into settings(stattr, stvalue) values ('timeout', '1 hr');

I would like to determine if this time has elapsed:
select selasthit - stvalue::interval as thetime from sessions, settings;
(obviously, there's only one row in my settings table for testing purposes)

I keep getting:
ERROR: Cannot cast type 'character varying' to 'interval'

Can anyone suggest a solution?

Thanks
Chris