Re: Re: Time Formats - Mailing list pgsql-general

From Robert B. Easter
Subject Re: Re: Time Formats
Date
Msg-id 01011715353708.02219@comptechnews
Whole thread Raw
In response to Re: Time Formats  (Jeffery L Post <postjeff@uwm.edu>)
List pgsql-general
Maybe try something like:

SELECT to_char(mytable.date + mytable.time, 'HH:MIAM');

That puts your separate date and time fields together into a timestamp, then
you can use to_char.

If you don't have a mytable.date, I think you could just do:

SELECT to_char(CURRENT_DATE + mytable.time, 'HH:MIAM');

In formatting the time part, I don't think it will look at the date part at
all.  It might not matter what the date actually is in there.


On Wednesday 17 January 2001 12:20, Jeffery L Post wrote:
> Well I finaly got around to trying the to_char function. And I am having
> difficulty getting it to do what I want elegantly.
>
> Here is the situation...
> I am tracking the time that an event occurs in a column of type time.
> (seperate column for date).  I want to display the time of the event in a
> fool proof HH:MM (AM | PM) format. As far as I can tell the to_char()
> function is not overloaded for the time type just timestamp.
>
> How do I format a column of type time to HH:MM AM | PM ?
> I belive the now() function returns a timestamp. but I need a strict time
> datatype example.
>
> Thanks again
> Jeff Post
> University of Wisconsin - Milwaukee

--
-------- Robert B. Easter  reaster@comptechnews.com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

pgsql-general by date:

Previous
From: pov@club-internet.fr (Yann Coupin)
Date:
Subject: Re: Problem with indexes
Next
From: Travis Bauer
Date:
Subject: plperl and sqrt.