- publishing free software manuals
The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group
Paperback (6"x9"), 478 pages
ISBN 9781906966065
RRP £14.95 ($19.95)

Sales of this book support the PostgreSQL project! Get a printed copy>>>

3.8.4 The interval type

The interval type in C enables your programs to deal with data of the SQL type interval. See Volume 1A: 6.5 Date/Time Types for the equivalent type in the PostgreSQL server.

The following functions can be used to work with the interval type:

Return a pointer to a newly allocated interval variable.
interval *PGTYPESinterval_new(void);
Release the memory of a previously allocated interval variable.
void PGTYPESinterval_new(interval *intvl);
Parse an interval from its textual representation.
interval *PGTYPESinterval_from_asc(char *str, char **endptr);
The function parses the input string str and returns a pointer to an allocated interval variable. At the moment ECPG always parses the complete string and so it currently does not support storing the address of the first invalid character in *endptr. You can safely set endptr to NULL.
Convert a variable of type interval to its textual representation.
char *PGTYPESinterval_to_asc(interval *span);
The function converts the interval variable that span points to into a C char*. The output looks like this example: @ 1 day 12 hours 59 mins 10 secs.
Copy a variable of type interval.
int PGTYPESinterval_copy(interval *intvlsrc, interval 
The function copies the interval variable that intvlsrc points to into the variable that intvldest points to. Note that you need to allocate the memory for the destination variable before.
ISBN 9781906966065The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming GuideSee the print edition