Thread: New and Timestamp Question

New and Timestamp Question

From
Dawn Albrecht
Date:
Greets,

I am new to postgres and I'm not even sure if I'm
writing to the correct place but here it goes:

All I want to do is change the timestamp format.  I
can change the 'date' part of it, but the time is
always delivered as: 14:00:00 instead of 2:00:00 PM.
I do not wish to view army time, but regular
non-military time.

I used the Set datestyle command and no matter what I
set it to, the date itself changes, but not the time
format?

Any suggestions?  I will be using the timestamp field
on an ASP and JSP page and I was hoping to just modify
its view in the database itself.

Thank you,

DA

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: New and Timestamp Question

From
Bruno Wolff III
Date:
On Fri, Aug 15, 2003 at 04:30:02 -0700,
  Dawn Albrecht <oinee@yahoo.com> wrote:
>
> All I want to do is change the timestamp format.  I
> can change the 'date' part of it, but the time is
> always delivered as: 14:00:00 instead of 2:00:00 PM.
> I do not wish to view army time, but regular
> non-military time.

You can use to_char to get the time in the repsentation you want.

Re: New and Timestamp Question

From
Bruno Wolff III
Date:
You should keep discussions on the list as other people may be able to help you
and other people might be interested in any solutions that are given.

On Mon, Aug 18, 2003 at 06:52:03 -0700,
  Dawn Albrecht <oinee@yahoo.com> wrote:
> I have searched the list archives, but have not found
> anything that specifically addresses this.  Where
> would you use the to_char?  I want to change the view
> of it in the actual table but still be treated as a
> date/time.

This sounds like you are trying to do something like you might for a
spread sheet where you can supply formats for outputting data for
the various columns.

Things don't work like that in Postgres (and probably most databases).
When you want to look at the data, you use formatting functions such
as to_char to provide output in the desired format.

So to see time in a 12 hour format you might do something like:
select to_char(column,'HH12:MI');

If you don't want to scatter to_char's all over the place, then you might
want to create view and use that to look at the table.