X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6709FD975F for ; Mon, 10 Oct 2005 00:13:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04047-07 for ; Mon, 10 Oct 2005 03:13:19 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 1694BD9819 for ; Mon, 10 Oct 2005 00:13:18 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j9A3DDpE081161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 9 Oct 2005 21:13:15 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j9A3DCFL073763; Sun, 9 Oct 2005 21:13:13 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j9A3DCbl073762; Sun, 9 Oct 2005 21:13:12 -0600 (MDT) (envelope-from mfuhr) Date: Sun, 9 Oct 2005 21:13:12 -0600 From: Michael Fuhr To: Simon Law Cc: pgsql-sql@postgresql.org Subject: Re: convert time Message-ID: <20051010031312.GA67346@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/76 X-Sequence-Number: 22929 On Sun, Oct 09, 2005 at 07:20:53PM -0400, Simon Law wrote: > Is there a way for postgres to output using the 12 hour standard > instead of army time? The column is of type time By "army time" I assume you mean 24-hour time, which is widely used in non-military settings, especially outside the United States. In many countries, 24-hour time is just as "standard" as 12-hour time, and is understood by the population at large because it's the usual format for TV and radio schedules, train and bus timetables, etc. It was a bright cold day in April, and the clocks were striking thirteen. --Opening sentence of _1984_ by George Orwell You can use to_char() to format time types, although it apparently works via an implicit cast to interval, as Bruce Momjian explains in the following message: http://archives.postgresql.org/pgsql-bugs/2005-02/msg00245.php See "Data Type Formatting Functions" in the documentation to learn how to use to_char(): http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html Example: CREATE TABLE foo (t time); INSERT INTO foo (t) VALUES ('08:00:00'); INSERT INTO foo (t) VALUES ('20:00:00'); SELECT t, to_char(t, 'HH12:MI:SSam') FROM foo; t | to_char ----------+------------ 08:00:00 | 08:00:00am 20:00:00 | 08:00:00pm (2 rows) -- Michael Fuhr