From: Ranieri Mazili <ranieri.oliveira@terra.com.br>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: Re: Working with dates
Date: Thu, 05 Jul 2007 17:49:29 -0300
Message-ID: <468D5959.7090404@terra.com.br> (raw)
In-Reply-To: <468D3FD8.7070807@terra.com.br>
References: <468D3FD8.7070807@terra.com.br>
-------- 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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ranieri.oliveira@terra.com.br, pgsql-general@postgresql.org
Subject: Re: Working with dates
In-Reply-To: <468D5959.7090404@terra.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox