Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i2s0I-0005M6-5x for pgsql-general@arkaria.postgresql.org; Wed, 28 Aug 2019 07:04:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i2s0G-0007mb-U8 for pgsql-general@arkaria.postgresql.org; Wed, 28 Aug 2019 07:04:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i2s0G-0007f6-6n for pgsql-general@lists.postgresql.org; Wed, 28 Aug 2019 07:04:24 +0000 Received: from mail.wordtothewise.com ([104.225.223.158]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i2s08-0005Cr-6T for pgsql-general@postgresql.org; Wed, 28 Aug 2019 07:04:23 +0000 Received: from [192.168.0.88] (unknown [37.228.251.105]) by mail.wordtothewise.com (Postfix) with ESMTPSA id 7ABD49F147 for ; Wed, 28 Aug 2019 00:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wordtothewise.com; s=aardvark; t=1566975853; bh=bfv5jilDGTqogFfXQR4SrhvLWXy3XS0tRdR9sEVPxxI=; h=From:Subject:Date:References:To:In-Reply-To:From; b=QmnpPlwlhzvvWsyJ+YPOPEyVEwIDGnRmuhBVvNIUXKuu6+U838/vsm2oRcGH7x9MP UaqfpxsUkEJp2lx8+dkPOSfGwaeMwhg19Yb4F9U+ZEjcMGLQKM568NWavNeUszMZjj 7XWBO117pqCl/60t6gnCJb9mFX332/viBKm4Dmuo= From: Steve Atkins Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Work hours? Date: Wed, 28 Aug 2019 08:04:11 +0100 References: <20190827222741.GB19306@panix.com> To: pgsql-general In-Reply-To: <20190827222741.GB19306@panix.com> Message-Id: <8CD2FD0C-003D-44E5-A614-D4617867E025@blighty.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Aug 27, 2019, at 11:27 PM, stan wrote: >=20 > I am just starting to explore the power of PostgreSQL's time and date > functionality. I must say they seem very powerful. >=20 > I need to write a function that, given a month, and a year as input = returns > the "work hours" in that month. In other words something like >=20 > 8 * the count of all days in the range Monday to Friday) within that > calendar month. >=20 > Any thoughts as to the best way to approach this? You might find this useful: = https://gist.github.com/wttw/b6f5d0d67c31d499c05f22a4f2b6f628 It's not the most efficient approach, but it's relatively simple to = customize. Cheers, Steve