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 1gpIk3-0006s7-BM for pgsql-general@arkaria.postgresql.org; Thu, 31 Jan 2019 20:15:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gpIk2-0003w5-27 for pgsql-general@arkaria.postgresql.org; Thu, 31 Jan 2019 20:15:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpIk1-0003vt-Mr for pgsql-general@lists.postgresql.org; Thu, 31 Jan 2019 20:15:17 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpIjz-0008Ck-08 for pgsql-general@postgresql.org; Thu, 31 Jan 2019 20:15:16 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1gpIjy-0005pa-7w; Thu, 31 Jan 2019 15:15:14 -0500 Date: Thu, 31 Jan 2019 15:15:14 -0500 From: Bruce Momjian To: Ron Cc: pgsql-general@postgresql.org Subject: Re: Date calculation Message-ID: <20190131201514.GA3377@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jan 31, 2019 at 02:11:14PM -0600, Ron wrote: > Hi, > > v9.6.6 > > Is there a built in function to calculate, for example, next Sunday? > > For example, > > postgres=# select current_date, next_dow(current_date, 'Sunday'); >     date    |    date > ------------|------------ >  2019-01-31 | 2019-02-03 > (1 row) Uh, this worked: SELECT date_trunc('week', CURRENT_TIMESTAMP) + '6 days'; ?column? ------------------------ 2019-02-03 00:00:00-05 -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +