Re: Extract Function - Mailing list pgsql-novice

From Tom Lane
Subject Re: Extract Function
Date
Msg-id 26255.1080328789@sss.pgh.pa.us
Whole thread Raw
In response to Extract Function  ("Derrick Betts" <Derrick@Blue-Axis.com>)
List pgsql-novice
"Derrick Betts" <Derrick@Blue-Axis.com> writes:
> This is the command:
> SELECT EXTRACT(EPOCH FROM TIMESTAMP variable_name) INTO Temp;

You're confusing the EXTRACT function with the notation for a literal
constant of a specific type.  The function is just

    EXTRACT(EPOCH FROM timestamp-expression)

An example that involves a literal constant could be written either

    EXTRACT(EPOCH FROM TIMESTAMP '2004-1-10 00:00:00')
    EXTRACT(EPOCH FROM '2004-1-10 00:00:00'::TIMESTAMP)

but when you are dealing with a variable you don't use the TIMESTAMP
decoration, because the parser already knows what datatype the variable
is.  So

    EXTRACT(EPOCH FROM timestamp-variable)

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: how to test string against regular expression contained in postgresql database field?
Next
From: Aarni Ruuhimäki
Date:
Subject: Re: Upgrading PostgreSQL