Date Question

Поиск
Список
Период
Сортировка
От Sharon Cowling
Тема Date Question
Дата
Msg-id 200206262250.g5QMo7F18897@lambton.sslnz.com
обсуждение исходный текст
Ответы Re: Date Question  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-novice
Hi,

I have a query that is not returning the desired results.  I want the results to be a list of permit_id's held between
2dates, but the results I'm getting is only those permit_id's that start on date_from ('27-06-02') and finish on
date_to('11-07-02'), I also want the permit_id's returned for those permits that are held within that time period, for
examplea permit that starts on 20-06-02 and finishes on 04-07-02.  I've tried all sorts of variations but I'm still not
gettingthe right results, anyone have any ideas? 

SELECT permit_id
FROM faps_permit
WHERE person_id = (select person_id from person where person_id = 100)
AND cancel_permit is null
AND location = 'Kent Forest'
AND ( (date_from >= '27-06-02' AND date_to <= '11-07-02')
OR (date_from <= '27-06-02' AND date_to >= '11-07-02') )
ORDER BY permit_id ;

(Please note that this query is being used in a Java application and the values shown here are examples)

Regards,

Sharon Cowling




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

Предыдущее
От: Doug Silver
Дата:
Сообщение: Can't get pg_hba.conf to work
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Can't get pg_hba.conf to work