Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group