Skip site navigation (1) Skip section navigation (2)

Re: Convert INT to INTERVAL?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brian Knox <laotse(at)aol(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Convert INT to INTERVAL?
Date: 2004-02-27 18:12:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Brian Knox <laotse(at)aol(dot)net> writes:
> Is it possible within pl/pgsql, to convert an integer to an interval in 
> months? IE, if num_months is an INT set to 48, can it be converted to an 
> interval?

Sure, just multiply by the appropriate interval value:

regression=# select 48 * '1 month'::interval;
 4 years
(1 row)

			regards, tom lane

In response to


pgsql-sql by date

Next:From: JJ GaborDate: 2004-02-27 22:18:44
Subject: VIEW on lookup table
Previous:From: Michael ChaneyDate: 2004-02-27 18:07:05
Subject: Re: Convert INT to INTERVAL?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group