pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedconvert time
2+ messages / 2 participants
[nested] [flat]
* convert time
@ 2005-10-09 23:20 Simon Law <simonslaw@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Simon Law @ 2005-10-09 23:20 UTC (permalink / raw)
To: pgsql-sql
Is there a way for postgres to output using the 12 hour standard
instead of army time? The column is of type time
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: convert time
@ 2005-10-10 03:13 Michael Fuhr <mike@fuhr.org>
parent: Simon Law <simonslaw@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Fuhr @ 2005-10-10 03:13 UTC (permalink / raw)
To: Simon Law <simonslaw@gmail.com>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-10-10 03:13 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-09 23:20 convert time Simon Law <simonslaw@gmail.com>
2005-10-10 03:13 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox