Search Postgresql Archives

Re: Date calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux