Thread: Casting varchar to interval

Casting varchar to interval

From
Chris
Date:
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