| From: | Bruce Momjian <bruce(at)momjian(dot)us> |
|---|---|
| To: | Ron <ronljohnsonjr(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Date calculation |
| Date: | 2019-01-31 20:23:40 |
| Message-ID: | 20190131202340.GB3377@momjian.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Jan 31, 2019 at 02:21:52PM -0600, Ron wrote:
> 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...
Oh, right, you want date, so use:
SELECT date_trunc('week', CURRENT_DATE) + '6 days';
?column?
------------------------
2019-02-03 00:00:00-05
--
Bruce Momjian <bruce(at)momjian(dot)us> 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 +
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Gierth | 2019-01-31 20:53:07 | Re: Date calculation |
| Previous Message | Ron | 2019-01-31 20:21:52 | Re: Date calculation |