Re: Date calculation

2019-01-31 Thread Andrew Gierth
> "Bruce" == Bruce Momjian writes: Bruce> Oh, right, you want date, so use: Bruce> SELECT date_trunc('week', CURRENT_DATE) + '6 days'; Three major things wrong with this: 1. If you do this on Sunday, it gives you the current day not the _next_ Sunday. 2. If you try and do this for other

Re: Date calculation

2019-01-31 Thread Andrew Gierth
> "Ron" == Ron writes: Ron> Hi, Ron> v9.6.6 Ron> Is there a built in function to calculate, for example, next Ron> Sunday? No, but such things aren't hard to calculate using the available primitives. To get "next Xday", for example, you can add 7 days and then do "previous or current

Re: Date calculation

2019-01-31 Thread Bruce Momjian
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=# sel

Re: Date calculation

2019-01-31 Thread Ron
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 |---

Re: Date calculation

2019-01-31 Thread Bruce Momjian
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