Re: How to timestamp - Mailing list pgsql-general

From 100.179370@germanynet.de (Martin Jacobs)
Subject Re: How to timestamp
Date
Msg-id Pine.LNX.4.33.0201051342080.9507-100000@Schnecke.Windsbach.de
Whole thread Raw
In response to How to timestamp  ("Alex Cheung Tin Ka [CD]" <tkcheung@vtc.edu.hk>)
List pgsql-general
Hi Alex,

On Thu, 27 Dec 2001, Alex Cheung Tin Ka [CD] wrote:

> Dear everybody,
>     I would like to know how to create a timestamp value without time zone.
>     I have encountered a problem that I have set following values in the table.
>
>     create table test(
>          a timestamp without time zone

There is a data type without time zone. It's just called
'timestamp'

So try:

    create table test (a timestamp);
    insert into test (a) values (current_timestamp);
    select * from test;

and you will get something like:

     2002-01-05 13:40:29+01

According to PostgreSQL documentation all timestamp data is
displayed with time zone info in various flavours (ISO, SQL,
Postgres, national variants, ...). Data type 'timestamp'
stores it's data without timezone in contrast to data type
'timestamp with time zone'. For timestamp without time zone
PostgreSQL assumes time zone of your machine.

Timestamp data is 8 byte numeric data, what you see is a
converted character represenation. To get your own character
representaion of timestamp, use conversion function to_char(),
example:

    select to_char(a, 'YY-MM-DD HH24:MI:ss') from test;

could give you something like:

     2002-01-05 13:40:29

For more details have a look at Chapter 5 of PostgreSQL
documentation: 'Formatting Functions'


>     );
>     INSERT INTO test (a) VALUES(current_timestamp);
>
>     but the value of a always shows the zone value like this "2001-12-27 14:54:47+08"
>     How to get rid of the last "+08" value?
> ...

Hope this helps.

Martin

--
Dipl-Ing. Martin Jacobs * Germany
Registered Linux User #87175, http://counter.li.org/


pgsql-general by date:

Previous
From: "Brent R. Matzelle"
Date:
Subject: Re: PostgreSQL GUI
Next
From: Justin Clift
Date:
Subject: Re: PostgreSQL GUI