Subject Re: Ignore Seconds when getting unique list of times
Author Adam
--- In firebird-support@yahoogroups.com, "ra8009" <ra8009@...> wrote:
>
> 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?
>

The most sensible solution would be to write/find a UDF that chops the
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