Re: ERROR: operator does not exist: timestamp without time zone + integer

From: Ray O'Donnell <ray(at)rodonnell(dot)ie>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: ERROR: operator does not exist: timestamp without time zone + integer
Date: 2019-04-30 16:57:35
Message-ID: df556cf3-6cb8-6e9f-6585-8c3e045bccc0@rodonnell.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 30/04/2019 16:00, Andrew Gierth wrote:
>>>>>> "Adrian" == Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
>
> Adrian> Or cast to a date:
>
> Adrian> test=> select date_trunc('day', localtimestamp)::date + 7;
>
> yeesh. that's a very long-winded way to write current_date + 7

Well, current_date is different: current_date returns a date, so you
only have to do:

select current_date + 7;

The original question (if I remember correctly; have zapped it now) was
about adding an integer to a timestamp, hence the need to truncate it to
a date first as in Adrian's example above.

Ray.

--
Raymond O'Donnell // Galway // Ireland
ray(at)rodonnell(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-04-30 18:52:02 Re: Amazon Linux Support?
Previous Message Andrew Gierth 2019-04-30 15:00:02 Re: ERROR: operator does not exist: timestamp without time zone + integer