Search Postgresql Archives

Re: How to return an Int4 when subtracting dates/timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andre Lopes <lopes80andre@xxxxxxxxx> wrote:

> I need to return an Int4 when I do this king of select

> [code]
> select CURRENT_DATE - '2009-12-31' from tbl_sometable
> [/code]

> This select returns an Interval. How can I return an Integer? Like '138'

That expression returning an interval would be contradictory
to the documentation and a simple test:

| tim=# SELECT CURRENT_DATE - '2009-12-31';
|  ?column?
| ----------
|       138
| (1 Zeile)

| tim=# SELECT CURRENT_DATE::TIMESTAMP - '2009-12-31';
|  ?column?
| ----------
|  138 days
| (1 Zeile)

| tim=#

So how far away from "this kind of select" is your actual
query?

Tim


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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux