Subject | Re: Ignore Seconds when getting unique list of times |
---|---|
Author | Adam |
Post date | 2007-08-01T02:59:46Z |
--- In firebird-support@yahoogroups.com, "ra8009" <ra8009@...> wrote:
seconds off and do.
SELECT DISTINCT STRIPSECONDS(STARTTIME) FROM FOO;
It can be done though if you know about EXTRACT and CAST, but you need
to remember to be working with the right data types so your
calculations are not rounded.
SELECT DISTINCT CAST(CAST(STARTTIME AS DATE) AS TIMESTAMP) +
(CAST((EXTRACT(HOUR FROM STARTTIME)*60) + (EXTRACT(MINUTE FROM
STARTTIME)) AS DOUBLE PRECISION) / 1440) FROM FOO;
Adam
>The most sensible solution would be to write/find a UDF that chops the
> I want a list of the unique times in a time field, but I don't want
> the seconds considered. When I try SELECT (DISTINCT) it takes the
> seconds in account. How can I get the query to ignore them?
>
seconds off and do.
SELECT DISTINCT STRIPSECONDS(STARTTIME) FROM FOO;
It can be done though if you know about EXTRACT and CAST, but you need
to remember to be working with the right data types so your
calculations are not rounded.
SELECT DISTINCT CAST(CAST(STARTTIME AS DATE) AS TIMESTAMP) +
(CAST((EXTRACT(HOUR FROM STARTTIME)*60) + (EXTRACT(MINUTE FROM
STARTTIME)) AS DOUBLE PRECISION) / 1440) FROM FOO;
Adam