Re: is this my date problem - Mailing list pgsql-bugs

From Richard Ellis
Subject Re: is this my date problem
Date
Msg-id 20031002113122.GF2570@i386.dp100.com
Whole thread Raw
In response to Re: is this my date problem  (Theodore Petrosky <tedpet5@yahoo.com>)
List pgsql-bugs
On Wed, Oct 01, 2003 at 07:57:18PM -0700, Theodore Petrosky wrote:
> here  is the  actual query:
>
> agencysacks=# SELECT jobnumseq, (SELECT cname FROM
> clientinfo ci WHERE ci.acode = j.clientid) as client,
> shrtdesc, to_char(proofduedate, 'Dy FMMon DD, YYYY
> HH12 am') FROM jobs j WHERE proofduedate BETWEEN
> to_timestamp('01 October 2003 00:01', 'DD Month YYYY
> HH24:MI') AND to_timestamp ('01 October 2003 23:59',
> 'DD Month YYYY HH24:MI') ORDER BY client,
>...
> I am trying to create a 'today' type query. between
> october 1, 2003 00:01 am and october 1, 2003 23:59

If you want a "today" type query, why are you using between?  This
should work, and be a whole lot more reliable:

SELECT jobnumseq, (SELECT cname
                   FROM clientinfo ci
                   WHERE ci.acode = j.clientid) as client,
       shrtdesc,
       to_char(proofduedate, 'Dy FMMon DD, YYYY  HH12 am')
FROM jobs j
WHERE date(proofduedate) = '2003-10-01')
ORDER BY client,

or if you want to derive "today" automatically this should work:

SELECT jobnumseq, (SELECT cname
                   FROM clientinfo ci
                   WHERE ci.acode = j.clientid) as client,
       shrtdesc,
       to_char(proofduedate, 'Dy FMMon DD, YYYY  HH12 am')
FROM jobs j
WHERE date(proofduedate) = date(now()))
ORDER BY client,

pgsql-bugs by date:

Previous
From: Theodore Petrosky
Date:
Subject: Re: is this my date problem
Next
From: Max Kellermann
Date:
Subject: 7.3.4: memory leak in fe-exec.c:279 (realloc)