From: | Larry Rosenman <ler(at)lerctr(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Messy Casts, Is there a better way? |
Date: | 2002-10-15 10:16:19 |
Message-ID: | 1034676979.436.1.camel@lerlaptop.lerctr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have a table with the following, in part:
contract_start date
contract_term int (term in MONTHS)
I want to calculate the contract end date. I came up with:
CREATE FUNCTION "get_contract_end" (integer) RETURNS date AS 'SELECT
cast(contract_start + cast(cast(contract_term as text) || '' month'' as
interval) as date)
FROM circuit
WHERE internal_id = $1;' LANGUAGE 'sql';
Is there a better way?
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
From | Date | Subject | |
---|---|---|---|
Next Message | wishy wishy | 2002-10-15 11:46:37 | Re: foreign keys again |
Previous Message | Peter Galbavy | 2002-10-15 10:09:23 | Re: IGNORE ME how do i insert an empty string ? |