Re: Counting days ... - Mailing list pgsql-sql

From Frank Bax
Subject Re: Counting days ...
Date
Msg-id 47DBF3BD.9080306@sympatico.ca
Whole thread Raw
In response to Re: Counting days ...  (Aarni Ruuhimäki <aarni@kymi.com>)
Responses Re: Counting days ...
List pgsql-sql
Aarni Ruuhimäki wrote:
> So the WHERE clause would go like:
> 
> group_id = 1 AND res_start_day < '$date1' AND res_end_day >= '$date1' [AND 
> region_id = $region_id] [AND company_id = $company_id] [AND product_id = 
> $product_id]
> OR 
> group_id = 1 AND res_start_day = '$date1' AND res_end_day >= '$date1' [AND 
> region_id = $region_id] [AND company_id = $company_id] [AND product_id = 
> $product_id]
> OR
> group_id = 1 AND res_start_day >= '$date1' AND res_start_day < '$date2' AND 
> res_end_day >= '$date1' [AND region_id = $region_id] [AND company_id = 
> $company_id] [AND product_id = $product_id]


This is smaller; and should be equivalent:

group_id = 1 AND
( res_start_day <= '$date1' AND res_end_day >= '$date1'
OR
res_start_day >= '$date1' AND res_start_day < '$date2' )
[AND region_id = $region_id]
[AND company_id = $company_id]
[AND product_id =  $product_id]


pgsql-sql by date:

Previous
From: Aarni Ruuhimäki
Date:
Subject: Re: Counting days ...
Next
From: Aarni Ruuhimäki
Date:
Subject: Re: Counting days ...