From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Todd P Marek <affe23(at)somahq(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Mailing |
Date: | 2004-10-05 14:58:03 |
Message-ID: | 20041005075036.E25039@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 5 Oct 2004, Todd P Marek wrote:
> Hello-
>
> I am in the process of translating a site using mysql as the backend
> over to postgres. I have a lot of time data that I would like to
> display to the user in the form of a schedule.
>
> I am using the to_char function to make the times human friendly
>
> to_char(class_schedule.endtime, 'HH:MI:SS AM')
>
> which returns
>
> 06:30:00 AM - 07:30:00 AM
>
> I am really looking to get it outputting like this.
>
> 6:30 AM - 7:30 AM
For the seconds, do you want seconds if it's not 00, or do you just not
want seconds at all? Because removing :SS will get rid of the seconds
display.
For the leading 0s, you'd probably need to do a user defined function to
trim them off, but it'd probably be relatively simple use of ltrim, so you
might do something like:
create function format_time(time) returns text as '
select ltrim(to_char($1, ''HH:MI AM''), ''0'')' language 'sql';
From | Date | Subject | |
---|---|---|---|
Next Message | Robby Russell | 2004-10-05 14:58:23 | Re: Mailing |
Previous Message | Tom Lane | 2004-10-05 14:56:55 | Re: Mailing |