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

Re: Extract Function

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Derrick Betts <Derrick(at)Blue-Axis(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Extract Function
Date: 2004-03-26 18:56:44
Message-ID: 20040326105524.J73227@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, 19 Mar 2004, Derrick Betts wrote:

> I am trying to use the EXTRACT function in pl/pgsql and running into a problem.
>
> This is the command:
>
> SELECT EXTRACT(EPOCH FROM TIMESTAMP variable_name) INTO Temp;
>
> The variable_name is of type text (I've also tried it as type
> timestamp), but the parser breaks when it attempts to perform this
> function.  It works great when I substitute the variable_name with
> '2004-1-10 00:00:00' , however, when I use a variable, it doesn't.

TIMESTAMP <foo> is meant for timestamp literals.  If you want to
convert a value from one type to another, you probably want something
like CAST(variable_name AS TIMESTAMP)

In response to

pgsql-novice by date

Next:From: Ron St-PierreDate: 2004-03-26 19:15:30
Subject: Re: [NOVICE] Simple list tables question
Previous:From: Tom LaneDate: 2004-03-26 18:04:37
Subject: Re: Equivalent of mssql profiler?

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