From: Michael Fuhr <mike@fuhr.org>
To: Theodore Petrosky <tedpet5@yahoo.com>
Cc: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: question using 'between' in a sql query
Date: Sat, 3 Dec 2005 11:15:15 -0700
Message-ID: <20051203181515.GA12719@winnie.fuhr.org> (raw)
In-Reply-To: <20051203175416.31456.qmail@web31712.mail.mud.yahoo.com>
References: <20051203175416.31456.qmail@web31712.mail.mud.yahoo.com>
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
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: mike@fuhr.org, tedpet5@yahoo.com
Subject: Re: question using 'between' in a sql query
In-Reply-To: <20051203181515.GA12719@winnie.fuhr.org>
* 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