selects on datetime

From: Scot Brady <ScotB(at)fine(dot)com>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: selects on datetime
Date: 1999-03-03 01:53:09
Message-ID: 81CA33A8DC6DD211AA0300A0C95D659F719C@ADMIN401
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

I have a table w/ a field of type datetime. I would like to do something
like:
select count(jobs) for every day of a particular month and year.

my current select statement is:
Select count(job_id) from jobs where date_part('month',sub_dt)=2 and
date_part('year',sub_dt)=1999 and date_
part('day',sub_dt)=?";

I then execute the statement filling the placeholder with days 1..31

There has to be a better way to do this since the select has to go through
every row in the table. Any ideas?

thanks,
scot b.

Browse pgsql-general by date

  From Date Subject
Next Message Thomas G. Lockhart 1999-03-03 04:14:25 Re: [HACKERS] NUMERIC and Perl
Previous Message Paulo da Silva 1999-03-02 21:56:22 A security problem (newbie)