Re: How to timestamp

Поиск
Список
Период
Сортировка
От 100.179370@germanynet.de (Martin Jacobs)
Тема Re: How to timestamp
Дата
Msg-id Pine.LNX.4.33.0201051342080.9507-100000@Schnecke.Windsbach.de
обсуждение исходный текст
Ответ на How to timestamp  ("Alex Cheung Tin Ka [CD]" <tkcheung@vtc.edu.hk>)
Список 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 по дате отправления:

Предыдущее
От: "Brent R. Matzelle"
Дата:
Сообщение: Re: PostgreSQL GUI
Следующее
От: Justin Clift
Дата:
Сообщение: Re: PostgreSQL GUI