Re: [GENERAL] adding years to a date field

2011-04-06 Thread John R Pierce
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 in

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Steve Crawford
On 04/06/2011 12:28 PM, John R Pierce wrote: On 04/06/11 9:10 AM, Steve Crawford wrote: select ii_purchased + your_interval_field * '1 year'::date as date from inventory_item; that SHOULD be written as... select ii_purchased + your_interval_field * interval '1 year' as date from inventory_it

Re: [GENERAL] adding years to a date field

2011-04-06 Thread John R Pierce
On 04/06/11 9:10 AM, Steve Crawford wrote: select ii_purchased + your_interval_field * '1 year'::date as date from inventory_item; that SHOULD be written as... select ii_purchased + your_interval_field * interval '1 year' as date from inventory_item; -- Sent via pgsql-general mailing list

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Karsten Hilbert
On Wed, Apr 06, 2011 at 09:18:15AM -0700, Christine Penner wrote: > This still gave me a sytax error. The other suggestion to multiply > the interval field by 1 year also gave me a syntax error. ... > Any other suggestions? ... > Christine Penner > Ingenious Software Live up to to it ? Karst

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Christine Penner
This worked. Thanks Christine Penner Ingenious Software 250-352-9495 ch...@fp2.ca On 06/04/2011 9:23 AM, Osvaldo Kussama wrote: SELECT ii_purchased + ii_expected_life * '1 year'::interval FROM inventory_item;

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Michael Glaesemann
On Apr 6, 2011, at 12:18, Christine Penner wrote: > This still gave me a sytax error. The other suggestion to multiply the > interval field by 1 year also gave me a syntax error. What was the error? And it's preferable to do multiply rather than do the equivalent of an eval on some string. s

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Christine Penner
This still gave me a sytax error. The other suggestion to multiply the interval field by 1 year also gave me a syntax error. ii_purchased is a timestamp without time zone ii_expected_life is a smallint Any other suggestions? Christine Penner Ingenious Software 250-352-9495 ch...@fp2.ca On 06

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Steve Crawford
On 04/06/2011 08:54 AM, Christine Penner wrote: I have to add a number of years to a date field. The years come from another field in the table. I know I can do this: select (ii_purchased + interval '3 year') as date from inventory_item; But I need to replace the 3 in 3 years with another fie

Re: [GENERAL] adding years to a date field

2011-04-06 Thread Adrian Klaver
On 04/06/2011 08:54 AM, Christine Penner wrote: I have to add a number of years to a date field. The years come from another field in the table. I know I can do this: select (ii_purchased + interval '3 year') as date from inventory_item; But I need to replace the 3 in 3 years with another field