Casting varchar to interval.?

From: "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Casting varchar to interval.?
Date: 2004-01-26 12:57:30
Message-ID: 40150EBA.4@lorenso.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I was hoping to cast a varchar to an interval.
How is this done? Nobody has provided an answer to
this questing when asked in the past:

http://archives.postgresql.org/pgsql-general/2002-07/msg01482.php

I have a table 'config' that contains:

CREATE TABLE "public"."config" (
"config_key" VARCHAR(64) NOT NULL,
"config_value" VARCHAR(256) NOT NULL,
PRIMARY KEY("config_key")
) WITH OIDS;

So I can do this:

# SELECT config_value
# FROM config
# WHERE config_key = 'commission_withhold_interval';
config_value
--------------
1 month
(1 row)

But I can't do this:

# SELECT config_value::interval
# FROM config
# WHERE config_key = 'commission_withhold_interval';

ERROR: cannot cast type character varying to interval

Why doesn't that work?

Dante

----------
D. Dante Lorenso
dante(at)lorenso(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-26 14:25:29 Re: FAQ (disk space)
Previous Message D. Dante Lorenso 2004-01-26 11:47:04 Storing Configuration settings for a database?