pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedPostGreSQL Date Query?
8+ messages / 5 participants
[nested] [flat]
* PostGreSQL Date Query?
@ 2005-03-08 21:51 Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 20:43 ` Re: PostGreSQL Date Query? Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:44 ` Re: PostGreSQL Date Query? Diego Gil <diego@adminsa.com>
0 siblings, 3 replies; 8+ messages in thread
From: Lennie De Villiers @ 2005-03-08 21:51 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
I'm using Java together with PostGreSQL database.
I'm having a problem with a date query, when I write:
select sRescheduleDate, * from tbl_leads
where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <= '28/01/2005'
and bRescheduleCall = true
the query also return the values for "01/04/2005" where it should only
return those between that date range.
Anyone can help me.
Using Java 2 SE 1.4.2, PostGreSQL 8.0
Kind Regards,
Lennie De Villiers
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
@ 2005-03-10 20:38 ` Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 20:45 ` Re: PostGreSQL Date Query? Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:48 ` Re: PostGreSQL Date Query? Prasanth <dbadmin@nqadmin.com>
2 siblings, 2 replies; 8+ messages in thread
From: Scott Marlowe @ 2005-03-10 20:38 UTC (permalink / raw)
To: Lennie De Villiers <lenniedg@lando.co.za>; +Cc: pgsql-jdbc
On Tue, 2005-03-08 at 15:51, Lennie De Villiers wrote:
> Hi,
>
>
> I'm using Java together with PostGreSQL database.
>
>
>
> I'm having a problem with a date query, when I write:
>
>
>
> select sRescheduleDate, * from tbl_leads
>
> where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
> '28/01/2005'
>
> and bRescheduleCall = true
>
>
>
> the query also return the values for "01/04/2005" where it should only
> return those between that date range.
Sounds like your month and day are not where you think they are.
http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
@ 2005-03-10 20:45 ` Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:50 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
1 sibling, 1 reply; 8+ messages in thread
From: Dave Cramer @ 2005-03-10 20:45 UTC (permalink / raw)
To: Scott Marlowe <smarlowe@g2switchworks.com>; +Cc: Lennie De Villiers <lenniedg@lando.co.za>; pgsql-jdbc
That's what I thought too, but pg should give him an error if he is
asking for the 28th month.
Dave
Scott Marlowe wrote:
>On Tue, 2005-03-08 at 15:51, Lennie De Villiers wrote:
>
>
>>Hi,
>>
>>
>>I'm using Java together with PostGreSQL database.
>>
>>
>>
>>I'm having a problem with a date query, when I write:
>>
>>
>>
>>select sRescheduleDate, * from tbl_leads
>>
>>where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
>>'28/01/2005'
>>
>>and bRescheduleCall = true
>>
>>
>>
>>the query also return the values for "01/04/2005" where it should only
>>return those between that date range.
>>
>>
>
>Sounds like your month and day are not where you think they are.
>
>http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
>
>---------------------------(end of broadcast)---------------------------
>TIP 8: explain analyze is your friend
>
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 20:45 ` Re: PostGreSQL Date Query? Dave Cramer <pg@fastcrypt.com>
@ 2005-03-10 20:50 ` Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 21:00 ` Re: PostGreSQL Date Query? Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 8+ messages in thread
From: Scott Marlowe @ 2005-03-10 20:50 UTC (permalink / raw)
To: pg@fastcrypt.com; +Cc: Lennie De Villiers <lenniedg@lando.co.za>; pgsql-jdbc
You'd think that as the guy who'd pissed and moaned until the old
behaviour was changed I would have thought of that. but no...
Too much going on today. I bet it's a text field.
On Thu, 2005-03-10 at 14:45, Dave Cramer wrote:
> That's what I thought too, but pg should give him an error if he is
> asking for the 28th month.
>
> Dave
>
> Scott Marlowe wrote:
>
> >On Tue, 2005-03-08 at 15:51, Lennie De Villiers wrote:
> >
> >
> >>Hi,
> >>
> >>
> >>I'm using Java together with PostGreSQL database.
> >>
> >>
> >>
> >>I'm having a problem with a date query, when I write:
> >>
> >>
> >>
> >>select sRescheduleDate, * from tbl_leads
> >>
> >>where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
> >>'28/01/2005'
> >>
> >>and bRescheduleCall = true
> >>
> >>
> >>
> >>the query also return the values for "01/04/2005" where it should only
> >>return those between that date range.
> >>
> >>
> >
> >Sounds like your month and day are not where you think they are.
> >
> >http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 8: explain analyze is your friend
> >
> >
> >
> >
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 20:45 ` Re: PostGreSQL Date Query? Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:50 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
@ 2005-03-10 21:00 ` Dave Cramer <pg@fastcrypt.com>
0 siblings, 0 replies; 8+ messages in thread
From: Dave Cramer @ 2005-03-10 21:00 UTC (permalink / raw)
To: Scott Marlowe <smarlowe@g2switchworks.com>; +Cc: Lennie De Villiers <lenniedg@lando.co.za>; pgsql-jdbc
This is why I almost never, no make that never try to set a timestamp or
a date parameter in a java query without using prepared statements
let the driver work out the details...
Dave
Scott Marlowe wrote:
>You'd think that as the guy who'd pissed and moaned until the old
>behaviour was changed I would have thought of that. but no...
>
>Too much going on today. I bet it's a text field.
>
>On Thu, 2005-03-10 at 14:45, Dave Cramer wrote:
>
>
>>That's what I thought too, but pg should give him an error if he is
>>asking for the 28th month.
>>
>>Dave
>>
>>Scott Marlowe wrote:
>>
>>
>>
>>>On Tue, 2005-03-08 at 15:51, Lennie De Villiers wrote:
>>>
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>
>>>>I'm using Java together with PostGreSQL database.
>>>>
>>>>
>>>>
>>>>I'm having a problem with a date query, when I write:
>>>>
>>>>
>>>>
>>>>select sRescheduleDate, * from tbl_leads
>>>>
>>>>where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
>>>>'28/01/2005'
>>>>
>>>>and bRescheduleCall = true
>>>>
>>>>
>>>>
>>>>the query also return the values for "01/04/2005" where it should only
>>>>return those between that date range.
>>>>
>>>>
>>>>
>>>>
>>>Sounds like your month and day are not where you think they are.
>>>
>>>http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-DATETIME-INPUT
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 8: explain analyze is your friend
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Re: PostGreSQL Date Query? Scott Marlowe <smarlowe@g2switchworks.com>
@ 2005-03-10 20:48 ` Prasanth <dbadmin@nqadmin.com>
1 sibling, 0 replies; 8+ messages in thread
From: Prasanth @ 2005-03-10 20:48 UTC (permalink / raw)
To: Scott Marlowe <smarlowe@g2switchworks.com>; Lennie De Villiers <lenniedg@lando.co.za>; +Cc: pgsql-jdbc
>Sounds like your month and day are not where you think they are.
In which case you will get an error message saying that "date/time field
value out of range."
-Prasanth.
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Scott Marlowe
Sent: Thursday, March 10, 2005 2:39 PM
To: Lennie De Villiers
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] PostGreSQL Date Query?
On Tue, 2005-03-08 at 15:51, Lennie De Villiers wrote:
> Hi,
>
>
> I'm using Java together with PostGreSQL database.
>
>
>
> I'm having a problem with a date query, when I write:
>
>
>
> select sRescheduleDate, * from tbl_leads
>
> where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
> '28/01/2005'
>
> and bRescheduleCall = true
>
>
>
> the query also return the values for "01/04/2005" where it should only
> return those between that date range.
Sounds like your month and day are not where you think they are.
http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-DA
TETIME-INPUT
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
@ 2005-03-10 20:43 ` Dave Cramer <pg@fastcrypt.com>
2 siblings, 0 replies; 8+ messages in thread
From: Dave Cramer @ 2005-03-10 20:43 UTC (permalink / raw)
To: Lennie De Villiers <lenniedg@lando.co.za>; +Cc: pgsql-jdbc
That's very strange. have you tried the query in psql. Also you can use
the between clause.
I'd also recommend using prepared statements and setDate, just to make
sure the date is formatted correctly.
Dave
Lennie De Villiers wrote:
> Hi,
>
>
> I'm using Java together with PostGreSQL database.
>
>
>
> I'm having a problem with a date query, when I write:
>
>
>
> select sRescheduleDate, * from tbl_leads
>
> where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <= '28/01/2005'
>
> and bRescheduleCall = true
>
>
>
> the query also return the values for "01/04/2005" where it should only
> return those between that date range.
>
> Anyone can help me.
>
>
>
> Using Java 2 SE 1.4.2, PostGreSQL 8.0
>
>
> Kind Regards,
>
>
>
> Lennie De Villiers
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: PostGreSQL Date Query?
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
@ 2005-03-10 20:44 ` Diego Gil <diego@adminsa.com>
2 siblings, 0 replies; 8+ messages in thread
From: Diego Gil @ 2005-03-10 20:44 UTC (permalink / raw)
To: Lennie De Villiers <lenniedg@lando.co.za>; +Cc: pgsql-jdbc
Maybe you have a wrong datestyle format.
Try a query with '01/01/2005' and '01/28/2005' range, in month-day-year
format.
Diego.
El mar, 08-03-2005 a las 23:51 +0200, Lennie De Villiers escribió:
> Hi,
>
>
> I'm using Java together with PostGreSQL database.
>
>
>
> I'm having a problem with a date query, when I write:
>
>
>
> select sRescheduleDate, * from tbl_leads
>
> where sRescheduleDate >= '01/01/2005' AND sRescheduleDate <=
> '28/01/2005'
>
> and bRescheduleCall = true
>
>
>
> the query also return the values for "01/04/2005" where it should only
> return those between that date range.
>
> Anyone can help me.
>
>
>
> Using Java 2 SE 1.4.2, PostGreSQL 8.0
>
>
> Kind Regards,
>
>
>
> Lennie De Villiers
>
>
>
>
>
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2005-03-10 21:00 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08 21:51 PostGreSQL Date Query? Lennie De Villiers <lenniedg@lando.co.za>
2005-03-10 20:38 ` Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 20:45 ` Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:50 ` Scott Marlowe <smarlowe@g2switchworks.com>
2005-03-10 21:00 ` Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:48 ` Prasanth <dbadmin@nqadmin.com>
2005-03-10 20:43 ` Dave Cramer <pg@fastcrypt.com>
2005-03-10 20:44 ` Diego Gil <diego@adminsa.com>
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