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

Поиск
Список
Период
Сортировка
От Tim Landscheidt
Тема Re: How to return an Int4 when subtracting dates/timestamps
Дата
Msg-id m3y6fglrqu.fsf@passepartout.tim-landscheidt.de
обсуждение исходный текст
Ответ на How to return an Int4 when subtracting dates/timestamps  (Andre Lopes <lopes80andre@gmail.com>)
Список pgsql-general
Andre Lopes <lopes80andre@gmail.com> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Andre Lopes
Дата:
Сообщение: How to return an Int4 when subtracting dates/timestamps
Следующее
От: Brad Ediger
Дата:
Сообщение: ERROR: unrecognized time zone name: "UTC"