Subject Re: Question on Month date range in SELECT statements
Author mspencewasunavailable
--- In, <myles@...> wrote:
> This is probably an elementary question, but if I have a table of
> (millions) and they all have a TIMESTAMP column in them, and I
want to get a
> total count of the number of rows that are in the table for the
> month, are there any built in commands to do this in Firebird 1.5,
or do I
> have to write a stored procedure that will take into consideration
the date
> ranges of each month of the year to determine if a row is a
candidate for
> the current month?
> Thanks in advance for any advice.
> Myles
> ============================
> Myles Wakeham
> Director of Engineering
> Tech Solutions US, Inc.
> Scottsdale, Arizona USA
> Phone (480) 451-7440

You want EXTRACT. This works for me:

select count(*) from sometable
where EXTRACT(MONTH from timestampfield)
<> Extract(MONTH from CURRENT_DATE)

(with appropriate substitutions for sometable and
timestampfield, of course <g>).

Michael D. Spence
Mockingbird Data Systems, Inc.