Re: extracting date from timestamp

Поиск
Список
Период
Сортировка
От Alexander Borkowski
Тема Re: extracting date from timestamp
Дата
Msg-id 41F58F5C.1000707@abri.une.edu.au
обсуждение исходный текст
Ответ на extracting date from timestamp  ("Keith Worthington" <keithw@narrowpathinc.com>)
Ответы Re: extracting date from timestamp  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-novice
Hi Keith,

> I tried this
[...]
>    SELECT CAST(extract(year from min(scan_timestamp)) || extract(month from
> min(scan_timestamp)) || extract(day from min(scan_timestamp)) AS date)
>      INTO v_inventory_date
>      FROM inventory.tbl_scanner;

You have the order for pl/pgsql SELECT INTO wrong (target variable(s)
first, then the value(s) you want to assign) and it is easier to get at
the information you want using the date_trunc function. Try

SELECT INTO
v_inventory_date
CAST(date_trunc('day', min(scan_timestamp)) AS date)
FROM inventory.tbl_scanner;

instead.

HTH,

Alex

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

Предыдущее
От: "Keith Worthington"
Дата:
Сообщение: extracting date from timestamp
Следующее
От: Tom Lane
Дата:
Сообщение: Re: extracting date from timestamp