<varlistentry id="ecpg-pgtypes-numeric-to-long">
<term><function>PGTYPESnumeric_to_long</function></term>
<listitem>
<para>
Convert a variable of type numeric to long.
<synopsis>
int PGTYPESnumeric_to_long(numeric *nv, long *lp);
</synopsis>
The function converts the numeric value from the variable that
<literal>nv</literal> points to into the long integer variable that
<literal>lp</literal> points to. It returns 0 on success and -1 if an error
occurs, including overflow and underflow. On overflow, the global variable
<literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal>
and on underflow <literal>errno</literal> will be set to
<literal>PGTYPES_NUM_UNDERFLOW</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry id="ecpg-pgtypes-numeric-to-decimal">
<term><function>PGTYPESnumeric_to_decimal</function></term>
<listitem>
<para>
Convert a variable of type numeric to decimal.
<synopsis>
int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst);
</synopsis>
The function converts the numeric value from the variable that
<literal>src</literal> points to into the decimal variable that
<literal>dst</literal> points to. It returns 0 on success and -1 if an error
occurs, including overflow. On overflow, the global variable
<literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal>
additionally.
</para>
</listitem>
</varlistentry>
<varlistentry id="ecpg-pgtypes-numeric-from-decimal">
<term><function>PGTYPESnumeric_from_decimal</function></term>
<listitem>
<para>
Convert a variable of type decimal to numeric.
<synopsis>
int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst);
</synopsis>
The function converts the decimal value from the variable that
<literal>src</literal> points to into the numeric variable that
<literal>dst</literal> points to. It returns 0 on success and -1 if an error
occurs. Since the decimal type is implemented as a limited version of
the numeric type, overflow cannot occur with this conversion.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>
<sect2 id="ecpg-pgtypes-date">
<title>The date Type</title>
<para>
The date type in C enables your programs to deal with data of the SQL type
date. See <xref linkend="datatype-datetime"/> for the equivalent type in the
<productname>PostgreSQL</productname> server.
</para>
<para>
The following functions can be used to work with the date type:
<variablelist>
<varlistentry id="pgtypesdatefromtimestamp">
<term><function>PGTYPESdate_from_timestamp</function></term>
<listitem>
<para>
Extract the date part from a timestamp.
<synopsis>
date PGTYPESdate_from_timestamp(timestamp dt);
</synopsis>
The function receives a timestamp as its only argument and returns the
extracted date part from this timestamp.
</para>
</listitem>
</varlistentry>
<varlistentry id="pgtypesdatefromasc">
<term><function>PGTYPESdate_from_asc</function></term>
<listitem>
<para>
Parse a date from its textual representation.
<synopsis>
date PGTYPESdate_from_asc(char *str, char **endptr);
</synopsis>
The function receives a C char* string <literal>str</literal> and a pointer to
a C char* string <literal>endptr</literal>. 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 <literal>*endptr</literal>.
You can safely set <literal>endptr</literal> to NULL.
</para>
<para>
Note that the function always assumes MDY-formatted dates and there is
currently no variable to change that within ECPG.
</para>