From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Date calculation
Date: Thu, 31 Jan 2019 14:21:52 -0600
Message-ID: <24e5ee21-0b9f-e3c8-2553-817813a04593@gmail.com> (raw)
In-Reply-To: <20190131201514.GA3377@momjian.us>
References: <c10b17de-623b-4af3-8a8c-45c4a3a5826d@gmail.com>
<20190131201514.GA3377@momjian.us>
On 1/31/19 2:15 PM, Bruce Momjian wrote:
> 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
Perfect! All I had to do was cast that as DATE...
Thanks
--
Angular momentum makes the world go 'round.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Date calculation
In-Reply-To: <24e5ee21-0b9f-e3c8-2553-817813a04593@gmail.com>
References: <c10b17de-623b-4af3-8a8c-45c4a3a5826d@gmail.com> <20190131201514.GA3377@momjian.us> <24e5ee21-0b9f-e3c8-2553-817813a04593@gmail.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