Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5J2Xva91788 for ; Mon, 18 Jun 2001 22:33:57 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 73747 for ; Mon, 18 Jun 2001 19:33:52 -0700 From: "Josh Berkus" Subject: A cute little function To: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Mon, 18 Jun 2001 19:33:52 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/282 X-Sequence-Number: 3545 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@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco