| PostgreSQL Reference Manual - Volume 2 - Programming Guide by The PostgreSQL Global Development Group Paperback (6"x9"), 408 pages ISBN 0954612035 RRP £19.95 ($34.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 1: Date/Time Types for the equivalent type in the PostgreSQL server.
The following functions can be used to work with the interval type:
PGTYPESinterval_new-
Return a pointer to a newly allocated interval variable.
interval *PGTYPESinterval_new(void);
PGTYPESinterval_free-
Release the memory of a previously allocated interval variable.
void PGTYPESinterval_new(interval *intvl);
PGTYPESinterval_from_asc-
Parse an interval from its textual representation.
interval *PGTYPESinterval_from_asc(char *str, char **endptr);
The function parses the input stringstrand returns a pointer to an allocated interval variable. At the moment ecpg always parses the complete string and so it currently does not support to store the address of the first invalid character in*endptr. You can safely setendptrto NULL. PGTYPESinterval_to_asc-
Convert a variable of type interval to its textual representation.
char *PGTYPESinterval_to_asc(interval *span);
The function converts the interval variable thatspanpoints to into a C char*. The output looks like this example:@ 1 day 12 hours 59 mins 10 secs. PGTYPESinterval_copy-
Copy a variable of type interval.
int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);
The function copies the interval variable thatintvlsrcpoints to into the variable thatintvldestpoints to. Note that you need to allocate the memory for the destination variable before.
| ISBN 0954612035 | PostgreSQL Reference Manual - Volume 2 - Programming Guide | See the print edition |