Re: Working with dates

From: Ranieri Mazili <ranieri(dot)oliveira(at)terra(dot)com(dot)br>
To: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Working with dates
Date: 2007-07-05 20:49:29
Message-ID: 468D5959.7090404@terra.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

-------- Original Message --------
Subject: [GENERAL] Working with dates
From: Ranieri Mazili <ranieri(dot)oliveira(at)terra(dot)com(dot)br>
To: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David F. Johnson 2007-07-05 20:53:36 User-Defined Types
Previous Message Ranieri Mazili 2007-07-05 19:00:40 Working with dates

Browse pgsql-sql by date

  From Date Subject
Next Message Gary Stainburn 2007-07-06 13:25:08 select from table and add rows.
Previous Message Ranieri Mazili 2007-07-05 19:00:40 Working with dates