PostgreSQL-Supported Functions

This section lists the functions specific to PostgreSQL, with examples and corresponding results.

ABSTIME( timestamp )

Converts the timestamp value to ABSTIME type. This function is provided for backwords compatibility and may be removed in future versions. For example:

SELECT ABSTIME(CURRENT_TIMESTAMP) -> 2003-06-24 00:19:17-07
ACOS( number )

Returns the arc cosine of number ranging from -1 to 1. The result ranges from 0 to and is expressed in radians. For example:

SELECT ACOS( 0 ) -> 1.570796
AGE( timestamp )

Same meaning as AGE(CURRENT_DATE, timestamp ).

AGE( timestamp, timestamp )

Returns the time between the two timestamp values. For example:

SELECT AGE( '2003-12-31', CURRENT_TIMESTAMP )
6 mons 7 days 00:34:41.658325
AREA( object )

Returns the area of an item. For example:

SELECT AREA( BOX '((0,0),(1,1))' ) -> 1
ASCII( text )

Returns the ASCII code of the first character of text. For example:

SELECT ASCII('x') -> 120
ASIN( number )

Returns the arc sine of number ranging from -1 to 1. The resulting value ranges from -/2 to /2 and is expressed in radians. For example:

SELECT ASIN( 0 ) -> 0.000000
ATAN( number )

Returns the arctangent of number. The resulting value ranges from -/2 to /2 and is expressed in radians. For example:

SELECT ATAN( 3.1415 ) -> 1.262619
ATAN2( float1,float2 )

Returns the arctangent of the two float values. ATAN2( x,y ) is similar to ATAN( y/x ), with the exception that the signs of x and y are used to determine the quadrant ...

Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.