Re: Working with dates - Mailing list pgsql-general

From Ranieri Mazili
Subject Re: Working with dates
Date
Msg-id 468D5959.7090404@terra.com.br
Whole thread Raw
In response to Working with dates  (Ranieri Mazili <ranieri.oliveira@terra.com.br>)
List pgsql-general
-------- Original Message  --------
Subject: [GENERAL] Working with dates
From: Ranieri Mazili <ranieri.oliveira@terra.com.br>
To: pgsql-general@postgresql.org, pgsql-sql@postgresql.org
Date: 5/7/2007 16:00
> Hello,
>
> I need to do the following select:
>
> Number of days of month - weekends - holydays
>
> So this query will return the number of days that people can work
>
> Look that I have the holydays in one table, it's bellow:
>
> CREATE TABLE holidays
> (
>  id_holidays serial NOT NULL,
>  dt_holiday date,
>  holiday_description character varying(60),
>  input_date timestamp without time zone NOT NULL,
>  CONSTRAINT holidays_pkey PRIMARY KEY (id_holidays)
> )
>
> I have no idea of how do it
>
> If someone could help, I would appreciate.
>
> Thanks
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>
I can.

select count(A.data)
from (select (date_trunc('month',(select production_date from production
order by production_date desc limit 1)::date)::date + x * '1
day'::interval)::date as data from generate_series(0,31) x) A
where extract(month from A.data) = extract(month from (select
production_date from production order by production_date desc limit
1)::date )
and extract(dow from A.data) <> 0
and extract(dow from A.data) <> 6
and A.data not in (select dt_holiday from holidays)


pgsql-general by date:

Previous
From: Ranieri Mazili
Date:
Subject: Working with dates
Next
From: Martijn van Oosterhout
Date:
Subject: Re: simple query question to use with DBI selectall_hashref