Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 088E0477322 for ; Thu, 20 Jun 2002 21:09:42 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id DC981476320 for ; Thu, 20 Jun 2002 20:11:16 -0400 (EDT) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1551217 for pgsql-sql@postgresql.org; Thu, 20 Jun 2002 17:11:17 -0700 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-sql@postgresql.org Subject: SQL Challenge: Skip Weekends Date: Thu, 20 Jun 2002 17:13:03 -0700 X-Mailer: KMail [version 1.4] MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200206201713.03801.josh@agliodbs.com> X-Archive-Number: 200206/283 X-Sequence-Number: 8248 Folks, Hey, I need to write a date calculation function that calculates the date= =20 after a number of *workdays* from a specific date. I pretty much have the= =20 "skip holidays" part nailed down, but I don't have a really good way to ski= p=20 all weekends in the caluclation. Here's the ideas I've come up with: Idea #1: Use a reference table 1. Using a script, generate a table of all weekends from 2000 to 2050. 2. Increase the interval by the number of weekends that fall in the relevan= t=20 period. Idea #2: Some sort of calculation using 5/7 of the interval, adjusted=20 according to the day of the week of our starting date. My head hurts tryin= g=20 to figure this one out. --=20 -Josh Berkus