Re: adding years to a date field

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: adding years to a date field
Date: 2011-04-06 22:26:07
Message-ID: 4D9CE87F.6050002@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/06/11 1:18 PM, Steve Crawford wrote:
>> select ii_purchased + your_interval_field * interval '1 year' as date
>> from inventory_item;
>>
>>
>>
> Correct. I meant ...::interval...

FWIW, '1 year'::interval implies a cast, that is a postgresql-specific
notation for cast('1 year' as interval), while interval '1 year' is the
SQL standard notation for an interval constant. yes, the end results
are the same, the parser/optimizer will look at that cast and do it in
advance rather than at execution time since the input is invariant.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yang Zhang 2011-04-06 23:06:40 Preventing accidental non-SSL connections in psql?
Previous Message Yang Zhang 2011-04-06 21:17:55 Re: How to set password without echoing characters?