Re: Query not producing expected result

2019-05-02 Thread Adrian Klaver
On 5/2/19 12:57 AM, Francisco Olarte wrote: Adrian: On Wed, May 1, 2019 at 8:14 PM Adrian Klaver wrote: . select '2019-05-02'::timestamp <= '2019-05-01 24:00'::timestamp; And you'll see and out of range date selected. Technically it is correct as: test_(postgres)# select '2019-05-02'::ti

Re: Query not producing expected result

2019-05-02 Thread Francisco Olarte
Adrian: On Wed, May 1, 2019 at 8:14 PM Adrian Klaver wrote: . > > select '2019-05-02'::timestamp <= '2019-05-01 24:00'::timestamp; > > And you'll see and out of range date selected. > > Technically it is correct as: > test_(postgres)# select '2019-05-02'::timestamp; >timestamp > -

Re: Query not producing expected result

2019-05-01 Thread Adrian Klaver
On 5/1/19 11:04 AM, Francisco Olarte wrote: Adrian: On Wed, May 1, 2019 at 7:57 PM Adrian Klaver wrote: You will have to explain further as I am not seeing it: test_(postgres)# select '2019-05-01 9:52' <= '2019-05-01 24:00'::timestamp; ?column? -- t test_(postgres)# select '2019

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
On Wed, May 1, 2019 at 8:04 PM Adrian Klaver wrote: > You don't have to use the functions: > test_(postgres)# select dt_fld from dt_test where dt_fld <@ > '[2019-02-01, 2019-03-01)'::daterange ; I knew there have to be a cast syntax ( I should have said I try to avoid casts as well ). I will ta

Re: Query not producing expected result

2019-05-01 Thread Adrian Klaver
On 5/1/19 10:58 AM, Francisco Olarte wrote: Adrian.. On Wed, May 1, 2019 at 7:50 PM Adrian Klaver wrote: I should have made it clearer, my suggestion was mostly directed at Franciso's example. ... For this sort of thing, I have found range types to be a time and sanity saver. Just throwing i

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
Adrian: On Wed, May 1, 2019 at 7:57 PM Adrian Klaver wrote: > You will have to explain further as I am not seeing it: > test_(postgres)# select '2019-05-01 9:52' <= '2019-05-01 24:00'::timestamp; > ?column? > -- > t > > test_(postgres)# select '2019-05-01 24:00' <= '2019-05-01 24:00':

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
Adrian.. On Wed, May 1, 2019 at 7:50 PM Adrian Klaver wrote: > I should have made it clearer, my suggestion was mostly directed at > Franciso's example. ... > For this sort of thing, I have found range types to be a time and sanity > saver. Just throwing it out there. I've had problems with the

Re: Query not producing expected result

2019-05-01 Thread Chuck Martin
Ok, I see that my assumptions were incorrect. In this instance, the use of < date+1 will return what is expected, where my solution might not have. For other circumstances, I want to explore tsrange. And, no, I'm not in Avondale, CA, but Decatur, GA (a few miles from Avondale Estates, where I once

Re: Query not producing expected result

2019-05-01 Thread Adrian Klaver
On 5/1/19 10:51 AM, Francisco Olarte wrote: On Wed, May 1, 2019 at 7:37 PM Chuck Martin wrote: Something like daterange would be a solution in some circumstances, but this query is a user-generated one, and they don't have that much control over the query. It has to be modified as needed beh

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
On Wed, May 1, 2019 at 7:37 PM Chuck Martin wrote: > > Something like daterange would be a solution in some circumstances, but this > query is a user-generated one, and they don't have that much control over the > query. It has to be modified as needed behind the scenes so that it produces > th

Re: Query not producing expected result

2019-05-01 Thread Adrian Klaver
On 5/1/19 10:37 AM, Chuck Martin wrote: Something like daterange would be a solution in some circumstances, but this query is a user-generated one, and they don't have that much control over the query. It has to be modified as needed behind the scenes so that it produces the results they expect

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
Chuck: On Wed, May 1, 2019 at 7:23 PM Chuck Martin wrote: > > Thanks for the extra information. It is indeed an indexed column. I'll have > to think some more about how to address this in a general way, as this issue > can come up all over. I suppose using > > AND datetime <= 'May 1, 2019 24:00

Re: Query not producing expected result

2019-05-01 Thread Chuck Martin
Something like daterange would be a solution in some circumstances, but this query is a user-generated one, and they don't have that much control over the query. It has to be modified as needed behind the scenes so that it produces the results they expect. In this instance, I'm now (given the advic

Re: Query not producing expected result

2019-05-01 Thread Adrian Klaver
On 5/1/19 10:15 AM, Francisco Olarte wrote: Chuck: On Wed, May 1, 2019 at 6:56 PM Chuck Martin wrote: Thanks, guys. It should have been obvious to me, but wasn't. I found the correct result was returned with either AND event.DateTime <= 'May-1-2019 24:00' or AND event.DateTime::date <= 'May-1-

Re: Query not producing expected result

2019-05-01 Thread Chuck Martin
Thanks for the extra information. It is indeed an indexed column. I'll have to think some more about how to address this in a general way, as this issue can come up all over. I suppose using AND datetime <= 'May 1, 2019 24:00' would produce the same as AND datetime < 'May 2, 2019' wouldn't it?

Re: Query not producing expected result

2019-05-01 Thread Francisco Olarte
Chuck: On Wed, May 1, 2019 at 6:56 PM Chuck Martin wrote: > Thanks, guys. It should have been obvious to me, but wasn't. > I found the correct result was returned with either > AND event.DateTime <= 'May-1-2019 24:00' > or > AND event.DateTime::date <= 'May-1-2019' > The latter seems best. The l

Re: Query not producing expected result

2019-05-01 Thread Ron
On 5/1/19 11:39 AM, Julien Rouhaud wrote: On Wed, May 1, 2019 at 6:27 PM Chuck Martin wrote: I need help figuring out why a query is not returning the records I expect it to. I'm searching on a DateTime column (timestamp without time zone - not nullable). The query includes: AND event.Prim

Re: Query not producing expected result

2019-05-01 Thread Chuck Martin
Thanks, guys. It should have been obvious to me, but wasn't. I found the correct result was returned with either AND event.DateTime <= 'May-1-2019 24:00' or AND event.DateTime::date <= 'May-1-2019' The latter seems best. Chuck Martin Avondale Software On Wed, May 1, 2019 at 12:41 PM Tom Lan

Re: Query not producing expected result

2019-05-01 Thread Tom Lane
Chuck Martin writes: > I need help figuring out why a query is not returning the records I expect > it to. I'm searching on a DateTime column (timestamp without time zone - > not nullable). The query includes: > AND event.Primaryresp_fkey = 511 AND event.DateTime <= 'May-1-2019' > AND event

Re: Query not producing expected result

2019-05-01 Thread David G. Johnston
On Wed, May 1, 2019 at 9:27 AM Chuck Martin wrote: > I need help figuring out why a query is not returning the records I expect > it to. I'm searching on a DateTime column (timestamp without time zone - > not nullable). The query includes: > > AND event.Primaryresp_fkey = 511 AND event.DateT

Re: Query not producing expected result

2019-05-01 Thread Julien Rouhaud
On Wed, May 1, 2019 at 6:27 PM Chuck Martin wrote: > > I need help figuring out why a query is not returning the records I expect it > to. I'm searching on a DateTime column (timestamp without time zone - not > nullable). The query includes: > > AND event.Primaryresp_fkey = 511 AND event.Da

Query not producing expected result

2019-05-01 Thread Chuck Martin
I need help figuring out why a query is not returning the records I expect it to. I'm searching on a DateTime column (timestamp without time zone - not nullable). The query includes: AND event.Primaryresp_fkey = 511 AND event.DateTime <= 'May-1-2019' AND event.EventDone < 1 This does not re