From: | Alexander Borkowski <alexander(dot)borkowski(at)abri(dot)une(dot)edu(dot)au> |
---|---|
To: | "Rodolfo J(dot) Paiz" <rpaiz(at)simpaticus(dot)com> |
Cc: | Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: SQL and function reference? |
Date: | 2005-01-26 23:26:19 |
Message-ID: | 41F8271B.7050606@abri.une.edu.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-01-26 23:34:49 | Re: SQL and function reference? |
Previous Message | operationsengineer1 | 2005-01-26 23:21:57 | Re: Postgres database access problem |