Re: counting days - Mailing list pgsql-general

From AgentM
Subject Re: counting days
Date
Msg-id D0787162-80A0-422D-824E-0217DF282E0F@themactionfaction.com
Whole thread Raw
In response to counting days  (garry saddington <garry@schoolteachers.co.uk>)
Responses Re: counting days  (Ragnar <gnari@hive.is>)
List pgsql-general
Perhaps you are trying to count business days? Those vary around the
world and you would certainly need a table to hold the holidays and
such. If you just want to count the number of non-weekend-days, then
get the interval as days and then it's a simple matter of math:

2*daysInterval/7+(daysInterval % 7 == 6 ? 1 : 0)

This holds assuming you are using dates and not timestamps- you may
wish to subtract 1 depending on what the dates represent.

-M

On Aug 29, 2006, at 14:35 , garry saddington wrote:

> I need to count the days between two dates that are not saturdays or
> sundays. I have read the manual and searched the lists but I am
> struggling. I can count the days but am finding difficulty
> excluding sat
> and sun from the count. I need this without reference to any tables.
> Does anyone have any pointers please.
> Regards


pgsql-general by date:

Previous
From: CSN
Date:
Subject: Re: database files are incompatible with server, after computer restart
Next
From: John Gray
Date:
Subject: Re: XPath and XML support