Re: question using 'between' in a sql query

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: question using 'between' in a sql query
Дата
Msg-id 20051203181515.GA12719@winnie.fuhr.org
обсуждение исходный текст
Ответ на question using 'between' in a sql query  (Theodore Petrosky <tedpet5@yahoo.com>)
Ответы Re: question using 'between' in a sql query  (Theodore Petrosky <tedpet5@yahoo.com>)
Список pgsql-sql
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'::timestampwith 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Theodore Petrosky
Дата:
Сообщение: question using 'between' in a sql query
Следующее
От: "Michael Avila"
Дата:
Сообщение: SQL Statement Help needed