pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: SQL Challenge:  Skip Weekends
Date: Thu, 20 Jun 2002 17:13:03 -0700
Message-ID: <200206201713.03801.josh@agliodbs.com> (raw)

Folks,

Hey, I need to write a date calculation function that calculates the date 
after a number of *workdays* from a specific date.   I pretty much have the 
"skip holidays" part nailed down, but I don't have a really good way to skip 
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 relevant 
period.

Idea #2:  Some sort of calculation using 5/7 of the interval, adjusted 
according to the day of the week of our starting date.  My head hurts trying 
to figure this one out.

-- 
-Josh Berkus






view thread (5+ messages)  latest in thread

Message-ID: <200206201713.03801.josh@agliodbs.com>
Permalink:  ../200206201713.03801.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200206201713.03801.josh@agliodbs.com

 · 

reply

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: josh@agliodbs.com
  Subject: Re: SQL Challenge:  Skip Weekends
  In-Reply-To: <200206201713.03801.josh@agliodbs.com>

* 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