Re: Programmatic access to interval units

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Nelson Green <nelsongreen84(at)gmail(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Programmatic access to interval units
Date: 2014-12-01 20:14:06
Message-ID: CAHyXU0y=bg-+PHVK6nFmGCAzj9D_Aw2Y3Gz9KeHwmeNejfo9vg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 1, 2014 at 10:42 AM, Nelson Green <nelsongreen84(at)gmail(dot)com> wrote:
> Good morning list,
>
> According to the documentation for interval data type inputs, the unit can
> be one of microsecond, millisecond, second, minute, hour, day, week, month,
> year, decade, century, or millennium. Are these units stored in a catalog
> somewhere? I would like to access them programmatically if possible, to
> validate input for a function I am developing.

if you're writing C, you can use libpqtypes to do this. It exposes the
interval as a C structure.

typedef struct
{
int years;
int mons;
int days;
int hours;
int mins;
int secs;
int usecs;
} PGinterval;

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Jeffries 2014-12-01 21:14:53 Irreversible SET ROLE
Previous Message Andres Freund 2014-12-01 18:08:09 Re: recovering from "too many failures" wal error