Timestamp and interval precision

Started by Vilson fariasover 22 years ago2 messagesgeneral
Jump to latest
#1Vilson farias
vilson.farias@digitro.com.br

Greetings,

I was doing some tests with timestamps and intervals and I've discovered,
for my surprise, that I can't set precision for resulting fields of type
interval when I'm executing a query. Please follow my tests :

bxs=# select CAST('10:32:14.553243' AS interval);
interval
-----------------
10:32:14.553243
(1 row)

bxs=# select CAST('10:32:14.553243' AS interval(0));
interval
-----------------
10:32:14.553243
(1 row)

But I can set precision when it's a timestamp :

bxs=# SELECT CAST('2003-10-09 23:45:34.543543' AS timestamp);
timestamp
----------------------------
2003-10-09 23:45:34.543543
(1 row)

bxs=# SELECT CAST('2003-10-09 23:45:34.543543' AS timestamp(0));
timestamp
---------------------
2003-10-09 23:45:35
(1 row)

Is it a known limitation?

Best regards,

----------------------------------------------------------------------------
----
Jos� Vilson de Mello de Farias
Software Engineer

D�gitro Tecnologia Ltda - www.digitro.com.br
APC - Customer Oriented Applications
E-mail: vilson.farias@digitro.com.br
Tel.: +55 48 281 7158
ICQ 11866179

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vilson farias (#1)
Re: Timestamp and interval precision

"Vilson farias" <vilson.farias@digitro.com.br> writes:

bxs=# select CAST('10:32:14.553243' AS interval(0));
interval
-----------------
10:32:14.553243
(1 row)

This is a known bug in 7.3 and before --- it's fixed for 7.4.

regards, tom lane