Subject | Re: Question on Month date range in SELECT statements |
---|---|
Author | mspencewasunavailable |
Post date | 2006-10-19T18:38:38Z |
--- In firebird-support@yahoogroups.com, <myles@...> wrote:
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.
>rows
> This is probably an elementary question, but if I have a table of
> (millions) and they all have a TIMESTAMP column in them, and Iwant to get a
> total count of the number of rows that are in the table for thecurrent
> 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 considerationthe date
> ranges of each month of the year to determine if a row is acandidate for
> the current month?You want EXTRACT. This works for me:
>
> Thanks in advance for any advice.
>
> Myles
>
> ============================
> Myles Wakeham
> Director of Engineering
> Tech Solutions US, Inc.
> Scottsdale, Arizona USA
> Phone (480) 451-7440
> www.techsol.org
>
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.