From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | A cute little function |
Date: | 2001-06-19 02:33:52 |
Message-ID: | web-73747@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Folks,
Here's a useful one:
CREATE FUNCTION qf_year_quarter (DATETIME) RETURNS VARCHAR AS '
SELECT CAST(CAST(EXTRACT(year FROM $1) AS VARCHAR) ||
'' Q'' || CAST(EXTRACT (quarter FROM $1) AS VARCHAR) AS VARCHAR);'
LANGUAGE 'sql';
SELECT qf_year_quarter('1999-11-01'::DATETIME);
--------------
1999 Q4
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Grant | 2001-06-19 05:12:51 | Sequence behaviour. |
Previous Message | Hugh Mandeville | 2001-06-19 02:13:06 | Re: storing special characters |