Re: Extract Function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Derrick Betts" <Derrick(at)Blue-Axis(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Extract Function
Date: 2004-03-26 19:19:49
Message-ID: 26255.1080328789@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Derrick Betts" <Derrick(at)Blue-Axis(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-03-26 19:33:27 Re: how to test string against regular expression contained in postgresql database field?
Previous Message Ron St-Pierre 2004-03-26 19:15:30 Re: [NOVICE] Simple list tables question