date + interval year - why is the return type convered to a timestamp?

View: New views
2 Messages — Rating Filter:   Alert me  

date + interval year - why is the return type convered to a timestamp?

by the6campbells :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why is Postgres returning a timestamp instead of the expected date data type for the first expression (the second returns a date)? 

In other words, is this a known bug or is it design intent. The manuals did not seem to appear to say this is intentional behaviour but is not SQL standard.

select date '2001-03-30' - interval '1' year, date '2001-03-30' - integer '365' from tversion




Re: date + interval year - why is the return type convered to a timestamp?

by Tom Lane-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

the6campbells <the6campbells@...> writes:
> Why is Postgres returning a timestamp instead of the expected date data type
> for the first expression (the second returns a date)?

> select date '2001-03-30' - interval '1' year, date '2001-03-30' - integer
> '365' from tversion

Would you expect a date for
        date '2001-03-30' - interval '1 hour'
?  They are type-wise the same case; we don't have different types for
different lengths of interval.

                        regards, tom lane

--
Sent via pgsql-sql mailing list (pgsql-sql@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql