pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: George Moga <george@flex.ro>
To: Paulo Roberto Kappke <paulok@cyclades.com.br>
To: SQL PostgreSQL <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Date type select
Date: Wed, 22 Sep 1999 15:37:21 +0000
Message-ID: <37E8F7B1.BB1B2F6F@flex.ro> (raw)
References: <37E7FF29.1BB059BC@unacs.bg>
	<37E8CBDE.B87F1653@sferacarta.com>
	<37E8D5C8.B1B97489@cyclades.com.br>

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





view thread (6+ messages)  latest in thread

Message-ID: <37E8F7B1.BB1B2F6F@flex.ro>
Permalink:  ../37E8F7B1.BB1B2F6F@flex.ro/
Also on:    postgresql.org/message-id/37E8F7B1.BB1B2F6F@flex.ro

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: george@flex.ro, paulok@cyclades.com.br
  Subject: Re: [SQL] Date type select
  In-Reply-To: <37E8F7B1.BB1B2F6F@flex.ro>
  References: <37E7FF29.1BB059BC@unacs.bg> <37E8CBDE.B87F1653@sferacarta.com> <37E8D5C8.B1B97489@cyclades.com.br> <37E8F7B1.BB1B2F6F@flex.ro>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox