Re: adding years to a date field
| От | Steve Crawford |
|---|---|
| Тема | Re: adding years to a date field |
| Дата | |
| Msg-id | 4D9C9092.3050600@pinpointresearch.com обсуждение исходный текст |
| Ответ на | adding years to a date field (Christine Penner <chris@fp2.ca>) |
| Ответы |
Re: adding years to a date field
|
| Список | pgsql-general |
On 04/06/2011 08:54 AM, Christine Penner wrote:
select ii_purchased + your_interval_field * '1 year'::date as date from inventory_item;
Cheers,
Steve
I have to add a number of years to a date field. The years come from another field in the table.Assuming that the field is an int, multiply the value in your years column by a 1-year interval:
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 from the same table ii_expected_life but I can't seem to do that without getting syntax errors-- Christine Penner Ingenious Software 250-352-9495 chris@fp2.ca
select ii_purchased + your_interval_field * '1 year'::date as date from inventory_item;
Cheers,
Steve
В списке pgsql-general по дате отправления: