Received: from ibm.cicnet.ro (IDENT:root@braila.cicnet.ro [193.231.113.254]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA80477 for ; Wed, 22 Sep 1999 11:42:46 -0400 (EDT) (envelope-from george@flex.ro) Received: from flex.ro (george@george.cicnet.ro [193.231.113.93]) by ibm.cicnet.ro (8.8.7/8.8.7) with ESMTP id SAA23701; Wed, 22 Sep 1999 18:42:20 +0300 Sender: george@cicnet.ro Message-ID: <37E8F7B1.BB1B2F6F@flex.ro> Date: Wed, 22 Sep 1999 15:37:21 +0000 From: George Moga Organization: Flex Consulting Braila, ROMANIA X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.5-15 i586) X-Accept-Language: ro MIME-Version: 1.0 To: Paulo Roberto Kappke , SQL PostgreSQL Subject: Re: [SQL] Date type select References: <37E7FF29.1BB059BC@unacs.bg> <37E8CBDE.B87F1653@sferacarta.com> <37E8D5C8.B1B97489@cyclades.com.br> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Paulo Roberto Kappke wrote: > Hi all, > > I'm having a problem to make a select statement with a date type field. > > I have a table with a field named date_in and this field is a date type. > Well, I need to do a select where the month is 09 and the year is 1999. > I tried: > > SELECT * FROM calls WHERE date_in LIKE '09%1999' ORDER BY date_in > or > SELECT * FROM calls WHERE date_in LIKE '09-__-1999' ORDER BY date_in > or > SELECT * FROM calls WHERE date_in LIKE '09%' AND date_in LIKE '%1999' > ORDER BY date_in > > using psql command and I received the following message: > > ERROR: There is more than one possible operator '~~' for types 'date' > and 'unknown' > You will have to retype this query using an explicit cast > > Could anybody help me ? > > Thanks in advance, > Paulo Kappke > Cyclades Brazil > > ************ Try this: select * from calls where date_part('month', date_in::datetime) = '09' and date_part('year', date_in::datetime) = '1999' order by date_in I use PostgreSQL 6.5.1 on RedHat Linux 6.0. -- Best, George Moga, george@flex.ro george@cicnet.ro