Re: SQL and function reference?

Поиск
Список
Период
Сортировка
От Alexander Borkowski
Тема Re: SQL and function reference?
Дата
Msg-id 41F8271B.7050606@abri.une.edu.au
обсуждение исходный текст
Ответ на Re: SQL and function reference?  ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>)
Ответы Re: SQL and function reference?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
> The idea here is to have a formula that says "select * from flights
> where date was less than 30 days ago"  and have that formula work
> properly.

How about:

select *
from flights
where date < cast(current_date + interval '30 days ago' as date);

(assuming there is a date column (of type date) on flights).

  So if I want to subtract two dates for this purpose, then I am
> going to need a today() function which I also have not found.
>
> I see now how the extract(epoch from interval) could be used, but then
> why is there no extract(days|months|hours from interval), or why can I
> not format an interval as "XXXXX seconds" or "YYY days"? Would make
> things so much simpler!

You can do this. For example

select current_timestamp + interval '1000000 seconds';

You can find the documentation on how to use the interval type in "Data
Types" / "Date/Time Types".

Cheers,

Alex

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

Предыдущее
От:
Дата:
Сообщение: Re: Postgres database access problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: SQL and function reference?