Subject | Subtracting minutes from a timestamp |
---|---|
Author | Garrett Smith |
Post date | 2005-01-04T05:36:03Z |
I'm wanting to select items that have a timestamp value that's a certain
number of minutes from current_timestamp. E.g., to select items that
have some_date within the last 10 minutes, I'm trying something like:
select * from foo where some_date - (10.0/(24.0*60.0)) >=
current_timestamp
This is based on the documentation that says the decimal portion of a
number is added as minutes to the timestamp value.
Apart from this being a very awkward way to express an interval, there
are rounding errors -- e.g. the expression of 10 minutes above appears
to behave more like 9 minutes.
Is there a better way to handle this?
-- Garrett
number of minutes from current_timestamp. E.g., to select items that
have some_date within the last 10 minutes, I'm trying something like:
select * from foo where some_date - (10.0/(24.0*60.0)) >=
current_timestamp
This is based on the documentation that says the decimal portion of a
number is added as minutes to the timestamp value.
Apart from this being a very awkward way to express an interval, there
are rounding errors -- e.g. the expression of 10 minutes above appears
to behave more like 9 minutes.
Is there a better way to handle this?
-- Garrett