Обсуждение: a date_part question

Поиск
Список
Период
Сортировка

a date_part question

От
Tony Grant
Дата:
Hello,

Why is date_part('year', timestamp) returning 1988.0?

timestamp is a timestampz field in the table.

Postgresql 7.3

Cheers

Tony Grant


Re: a date_part question

От
Richard Huxton
Дата:
On Wednesday 05 Mar 2003 9:06 pm, Tony Grant wrote:
> Hello,
>
> Why is date_part('year', timestamp) returning 1988.0?
>
> timestamp is a timestampz field in the table.
>
> Postgresql 7.3

Doesn't seem to reproduce here, though a field called timestamp strikes me as
confusing.

richardh=# CREATE TABLE bar (a text, timestamp timestamptz);
...
richardh=# SELECT * FROM bar;
 a |           timestamp
---+-------------------------------
 a | 2003-03-05 18:48:45.295279+00
 b | 2003-03-05 18:48:48.314004+00
 c | 2003-03-05 18:48:51.035841+00

richardh=# SELECT a,date_part('year',timestamp) FROM bar;
 a | date_part
---+-----------
 a |      2003
 b |      2003
 c |      2003

richardh=# select version();
                           version
-------------------------------------------------------------
 PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96

--
  Richard Huxton

Re: a date_part question

От
Tony Grant
Дата:
On Wed, 2003-03-05 at 13:51, Richard Huxton wrote:

>
> Doesn't seem to reproduce here, though a field called timestamp strikes me as
> confusing.

No the problem is the JSP front end which reads an integer and sticks .0
on the end...

to_char works just fine.

Cheers

Tony Grant

--
www.tgds.net Library management software toolkit,
redhat linux on Sony Vaio C1XD,
Dreamweaver MX with Tomcat and PostgreSQL