Re: Time Formatting

From: hodges(at)xprt(dot)net
To: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Time Formatting
Date: 2002-05-11 17:13:45
Message-ID: 3CDCEED9.7391.B3610B@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Problem solved.

I read the manual. The to_char function doesn't work
with type time. When I cast it to type timestamp the
database library I am using (php_lib_login and ADODB)
objects.

So I solved it with the php date and strtotime functions.
$time = $result->fields[3];
$time2 = (date("h:i a",strtotime($time)));

This allows flexible time display. My update and add
buttons both store correct data in the table.

Thanks for all the helpful suggestions,

Tom

On Sat, 2002-05-11 at 13:31, hodges(at)xprt(dot)net wrote:
> SELECT to_char( timestamp, 'HH12:MI am') FROM feasts;
> or time
> from psql prompt gives
> Function 'to_char(time, unknown)' does not exist
> Unable to identify a function that satisfies the given argument types
> you may need to add explicit typecasts
> time has the type of time

SELECT to_char( mytimefield::timestamp, 'HH12:MI am') FROM feasts;

And I can't recommend strongly enough that you read the manual, which is
quite clear on this sort of thing.

Regards,
Andrew.

> >
> > And for lots more information, look at the docs:
> >
> > >
> > > On 9 May 2002 at 20:55, Larry Rosenman wrote:
> > >
> > > > look at the to_char function on
> > > > http://www.lerctr.org/postgresql/functions-formatting.html
> > > >

--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Are you enrolled at http://schoolreunions.co.nz/ yet?

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Vijay Deval 2002-05-12 02:14:30 Re: What are schemas?
Previous Message Andrew McMillan 2002-05-11 04:16:06 Re: Time Formatting