date is not equals to dia/month/year: what's wrong? - Mailing list pgsql-sql

From Edipo E. F. Melo
Subject date is not equals to dia/month/year: what's wrong?
Date
Msg-id 200009261627.e8QGRoN13678@hub.org
Whole thread Raw
List pgsql-sql
Hi friends,
I was making a web app using Apache+PHP(4.0.1) and PostgreSQL
7.0.2, all running on OS/2 Warp FP12 (brazilian portuguese) and
discovered the following:

contas=> \d hipercard
                                    Table "hipercard" Attribute   |     Type     |                          
Modifier

--------------+--------------+------------------------------------------
--------
------------id_hipercard | integer      | not null default
nextval('hipercard_id_hipercard_
seq'::text)valor        | money        | not nulldatacompra   | date         | not nullparcelas     | integer      |
notnulldescricao    | varchar(240) |
 
Index: hipercard_pkey

contas=> select * from hipercard where id_hipercard=1;
id_hipercard |  valor  | datacompra | parcelas | descricao
--------------+---------+------------+----------+-----------           1 | $100.00 | 2000-04-30 |        1 |
(1 row)

contas=>select id_hipercard, valor, date_part('day', datacompra) as
"diaCompra", date_part('month', datacompra) as "mesCompra",
date_part('year', datacompra) as "anoCompra", parcelas, descricao from
hipercard where id_hipercard=1;
id_hipercard |  valor  | diaCompra | mesCompra | anoCompra | parcelas
|
descric
ao
--------------+---------+-----------+-----------+-----------+----------+
--------
---           1 | $100.00 |        29 |         4 |      2000 |        1
|
(1 row)
I'm doing something wrong? if the date is '2000-04-01', the
"frac-date-select" returns day: 31, month: 03, year 2000. More over:
'2000-01-01', splited: 31, 12, 1999.


   []'s
   Edipo Elder F. de Melo



pgsql-sql by date:

Previous
From: Karel Zak
Date:
Subject: Re: Data Type precision
Next
From: Jie Liang
Date:
Subject: Re: Data Type precision