Re: Date calculation

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Date calculation
Date: 2019-01-31 20:21:52
Message-ID: 24e5ee21-0b9f-e3c8-2553-817813a04593@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2019-01-31 20:23:40 Re: Date calculation
Previous Message legrand legrand 2019-01-31 20:16:21 Re: oracle_fwd - is it safe or not?