pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Date type select
6+ messages / 3 participants
[nested] [flat]

* Date type select
@ 1999-09-22 13:12 Paulo Roberto Kappke <paulok@cyclades.com.br>
  1999-09-22 15:37 ` Re: [SQL] Date type select George Moga <george@flex.ro>
  0 siblings, 1 reply; 6+ messages in thread

From: Paulo Roberto Kappke @ 1999-09-22 13:12 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Date type select
  1999-09-22 13:12 Date type select Paulo Roberto Kappke <paulok@cyclades.com.br>
@ 1999-09-22 15:37 ` George Moga <george@flex.ro>
  0 siblings, 0 replies; 6+ messages in thread

From: George Moga @ 1999-09-22 15:37 UTC (permalink / raw)
  To: Paulo Roberto Kappke <paulok@cyclades.com.br>; pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* RE: [SQL] Date type select
@ 1999-09-22 15:12 Jackson, DeJuan <djackson@cpsgroup.com>
  1999-09-22 17:47 ` Re: [SQL] Date type select Paulo Roberto Kappke <paulok@cyclades.com.br>
  0 siblings, 1 reply; 6+ messages in thread

From: Jackson, DeJuan @ 1999-09-22 15:12 UTC (permalink / raw)
  To: Paulo Roberto Kappke <paulok@cyclades.com.br>; pgsql-sql

template1=> select date_trunc('month', now());
date_trunc                  
----------------------------
Wed Sep 01 00:00:00 1999 CDT
(1 row)

template1=> select date_trunc('month', now()) = '9/1/1999';
?column?
--------
t       
(1 row)

Enjoy,
	DEJ

> -----Original Message-----
> From:	Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> Sent:	Wednesday, September 22, 1999 8:13 AM
> To:	pgsql-sql@postgreSQL.org
> Subject:	[SQL] Date type select
> 
> 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
> 
> ************



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Date type select
  1999-09-22 15:12 RE: [SQL] Date type select Jackson, DeJuan <djackson@cpsgroup.com>
@ 1999-09-22 17:47 ` Paulo Roberto Kappke <paulok@cyclades.com.br>
  0 siblings, 0 replies; 6+ messages in thread

From: Paulo Roberto Kappke @ 1999-09-22 17:47 UTC (permalink / raw)
  To: Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: pgsql-sql

OK DeJuan, but, probably your field's type is datetime and my type is
date. If I use your statement, I receive the following message:

ERROR: No such function 'date_in' with the specified attributes

By the way, I'm using the statement: 

SELECT * FROM calls WHERE date_in>='$month-01-$year' AND
date_in<='$month-31-$year' ORDER BY employee_nbr, date_in

And it works fine.

Thanks,
Paulo K

"Jackson, DeJuan" wrote:
> 
> template1=> select date_trunc('month', now());
> date_trunc
> ----------------------------
> Wed Sep 01 00:00:00 1999 CDT
> (1 row)
> 
> template1=> select date_trunc('month', now()) = '9/1/1999';
> ?column?
> --------
> t
> (1 row)
> 
> Enjoy,
>         DEJ
> 
> > -----Original Message-----
> > From: Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> > Sent: Wednesday, September 22, 1999 8:13 AM
> > To:   pgsql-sql@postgreSQL.org
> > Subject:      [SQL] Date type select
> >
> > 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
> >
> > ************



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* RE: [SQL] Date type select
@ 1999-09-22 17:52 Jackson, DeJuan <djackson@cpsgroup.com>
  1999-09-23 12:20 ` Re: [SQL] Date type select Paulo Roberto Kappke <paulok@cyclades.com.br>
  0 siblings, 1 reply; 6+ messages in thread

From: Jackson, DeJuan @ 1999-09-22 17:52 UTC (permalink / raw)
  To: Paulo Roberto Kappke <paulok@cyclades.com.br>; Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: pgsql-sql

I think you misunderstood, try:
SELECT * FROM calls
 WHERE date_trunc('month', date_in)='9/1/1999'
 ORDER BY employee_nbr, date_in;

'date_trunc' is the function not my field name.  Your method works well for
date but might not for daytime's because of the hour:minutes:seconds
specification, but that's another discussion.
	DEJ

> -----Original Message-----
> From:	Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> Sent:	Wednesday, September 22, 1999 12:48 PM
> To:	Jackson, DeJuan
> Cc:	pgsql-sql@postgreSQL.org
> Subject:	Re: [SQL] Date type select
> 
> OK DeJuan, but, probably your field's type is datetime and my type is
> date. If I use your statement, I receive the following message:
> 
> ERROR: No such function 'date_in' with the specified attributes
> 
> By the way, I'm using the statement: 
> 
> SELECT * FROM calls WHERE date_in>='$month-01-$year' AND
> date_in<='$month-31-$year' ORDER BY employee_nbr, date_in
> 
> And it works fine.
> 
> Thanks,
> Paulo K
> 
> "Jackson, DeJuan" wrote:
> > 
> > template1=> select date_trunc('month', now());
> > date_trunc
> > ----------------------------
> > Wed Sep 01 00:00:00 1999 CDT
> > (1 row)
> > 
> > template1=> select date_trunc('month', now()) = '9/1/1999';
> > ?column?
> > --------
> > t
> > (1 row)
> > 
> > Enjoy,
> >         DEJ
> > 
> > > -----Original Message-----
> > > From: Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> > > Sent: Wednesday, September 22, 1999 8:13 AM
> > > To:   pgsql-sql@postgreSQL.org
> > > Subject:      [SQL] Date type select
> > >
> > > 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
> > >
> > > ************



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Date type select
  1999-09-22 17:52 RE: [SQL] Date type select Jackson, DeJuan <djackson@cpsgroup.com>
@ 1999-09-23 12:20 ` Paulo Roberto Kappke <paulok@cyclades.com.br>
  0 siblings, 0 replies; 6+ messages in thread

From: Paulo Roberto Kappke @ 1999-09-23 12:20 UTC (permalink / raw)
  To: Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: pgsql-sql@postgreSQL.org, George Moga <george@flex.ro>

Yes, I made a big confusion.

The statement that you sent and George worked fine too.

Thanks,
Paulo K

"Jackson, DeJuan" wrote:
> 
> I think you misunderstood, try:
> SELECT * FROM calls
>  WHERE date_trunc('month', date_in)='9/1/1999'
>  ORDER BY employee_nbr, date_in;
> 
> 'date_trunc' is the function not my field name.  Your method works well for
> date but might not for daytime's because of the hour:minutes:seconds
> specification, but that's another discussion.
>         DEJ
> 
> > -----Original Message-----
> > From: Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> > Sent: Wednesday, September 22, 1999 12:48 PM
> > To:   Jackson, DeJuan
> > Cc:   pgsql-sql@postgreSQL.org
> > Subject:      Re: [SQL] Date type select
> >
> > OK DeJuan, but, probably your field's type is datetime and my type is
> > date. If I use your statement, I receive the following message:
> >
> > ERROR: No such function 'date_in' with the specified attributes
> >
> > By the way, I'm using the statement:
> >
> > SELECT * FROM calls WHERE date_in>='$month-01-$year' AND
> > date_in<='$month-31-$year' ORDER BY employee_nbr, date_in
> >
> > And it works fine.
> >
> > Thanks,
> > Paulo K
> >
> > "Jackson, DeJuan" wrote:
> > >
> > > template1=> select date_trunc('month', now());
> > > date_trunc
> > > ----------------------------
> > > Wed Sep 01 00:00:00 1999 CDT
> > > (1 row)
> > >
> > > template1=> select date_trunc('month', now()) = '9/1/1999';
> > > ?column?
> > > --------
> > > t
> > > (1 row)
> > >
> > > Enjoy,
> > >         DEJ
> > >
> > > > -----Original Message-----
> > > > From: Paulo Roberto Kappke [SMTP:paulok@cyclades.com.br]
> > > > Sent: Wednesday, September 22, 1999 8:13 AM
> > > > To:   pgsql-sql@postgreSQL.org
> > > > Subject:      [SQL] Date type select
> > > >
> > > > 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
> > > >
> > > > ************

-- 
_______________________________________________

Paulo Roberto Kappke
Web System Developer
voice: 55-11-5090-3341     fax:55-11-5090-3388
Cyclades Corporation - http://www.cyclades.com
Cyclades Brasil  -  http://www.cyclades.com.br
_______________________________________________



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~1999-09-23 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-22 13:12 Date type select Paulo Roberto Kappke <paulok@cyclades.com.br>
1999-09-22 15:37 ` George Moga <george@flex.ro>
1999-09-22 15:12 RE: [SQL] Date type select Jackson, DeJuan <djackson@cpsgroup.com>
1999-09-22 17:47 ` Paulo Roberto Kappke <paulok@cyclades.com.br>
1999-09-22 17:52 RE: [SQL] Date type select Jackson, DeJuan <djackson@cpsgroup.com>
1999-09-23 12:20 ` Paulo Roberto Kappke <paulok@cyclades.com.br>

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