From: Theodore Petrosky <tedpet5@yahoo.com>
To: Michael Fuhr <mike@fuhr.org>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: question using 'between' in a sql query
Date: Sun, 4 Dec 2005 08:28:54 -0800 (PST)
Message-ID: <20051204162854.79878.qmail@web31701.mail.mud.yahoo.com> (raw)
In-Reply-To: <20051203181515.GA12719@winnie.fuhr.org>
thanks... as is so often the case I discovered
date_trunc('day', insertdate) between '11/20/2005' AND
'11/20/2005' also works....
It wasn't until I pressed the send button that I
thought of the solution. I have thought of creating a
faux 'send' button for my email software... yours is a
little easier to read (human)..
Thanks again,
Ted
--- Michael Fuhr <mike@fuhr.org> wrote:
> On Sat, Dec 03, 2005 at 09:54:16AM -0800, Theodore
> Petrosky wrote:
> > if 'between' is inclusive of the start and end
> dates why doesn't
> > this query result in all the rows on '11/20/2005'?
>
> EXPLAIN shows what happens when you compare a date
> against a timestamp:
>
> Filter: ((insertdate >= '2005-11-20
> 00:00:00-08'::timestamp with time zone)
> AND (insertdate <= '2005-11-20
> 00:00:00-08'::timestamp with time zone))
>
> One way around this is to cast the timestamp column
> to date:
>
> SELECT employeecode
> FROM mytable
> WHERE insertdate::date BETWEEN '11/20/2005' AND
> '11/20/2005';
>
> --
> Michael Fuhr
>
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tedpet5@yahoo.com, mike@fuhr.org
Subject: Re: question using 'between' in a sql query
In-Reply-To: <20051204162854.79878.qmail@web31701.mail.mud.yahoo.com>
* 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