Re: deleting records is failing
От | Michael Glaesemann |
---|---|
Тема | Re: deleting records is failing |
Дата | |
Msg-id | 7A278D8C-3A76-4256-AA13-61373BF12820@myrealbox.com обсуждение исходный текст |
Ответ на | Re: deleting records is failing ("Tim Vadnais" <tvadnais@earthlink.net>) |
Список | pgsql-general |
On Dec 8, 2005, at 13:01 , Tim Vadnais wrote: > Thank you. > > I've modified the code to read: > > DELETE from tracker WHERE tracker.episode_id = 277 AND > tracker.date_of_service BETWEEN '09/12/2005'::date - interval '1 > day' AND > '10/20/2005'::date + interval '1 day' If you're going to be doing a lot of this, you might want to wrap it in a simple SQL function, such as : create or replace function oo_between ( date -- date to check , date -- start date of interval , date -- end date of interval ) returns boolean strict immutable language sql as $$ select $1 > $2 and $1 < $3; $$; Untested, and check the direction of the inequalities. I always seem to screw that up. I chose the oo_ prefix because this is sometimes called an open-open interval. BETWEEN on the other hand tests a closed-closed interval. You can call it like this: DELETE FROM tracker WHERE episode_id = 227 AND oo_between(date_of_service, '2005-09-12'::date, '2005-10-20'::date); Michael Glaesemann grzm myrealbox com
В списке pgsql-general по дате отправления: