Re: System Date

From: "Chad Wagner" <chad(dot)wagner(at)gmail(dot)com>
To: "Negandhi, Nishith" <Nishith(dot)Negandhi(at)infousa(dot)com>
Cc: "Benjamin Krajmalnik" <kraj(at)illumen(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: System Date
Date: 2007-01-19 00:10:55
Message-ID: 81961ff50701181610w6428119dke98d9fc52fa90a1c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 1/18/07, Negandhi, Nishith <Nishith(dot)Negandhi(at)infousa(dot)com> wrote:
>
> Hi Thanx..one more help.
> I am creating a function that will retuen the current systemdate.
>
> CREATE FUNCTION "CreateDate"() RETURNS date AS
> 'select now();'
> LANGUAGE 'plpgsql';
>
> However, I get the error:
>
> ERROR: syntax error at or near "select" at character 51
>
> Any suggestions .??
>
> Thanks in advance
>

Syntax is wrong, although I fail to see why you don't just use the "NOW()"
function. I guess I will assume this is just an example. :)

CREATE OR REPLACE FUNCTION "CreateDate"()
RETURNS DATE AS
$$
DECLARE
var_date date;
BEGIN
SELECT NOW()
INTO var_date;

RETURN var_date;
END;
$$ LANGUAGE 'plpgsql';

--
Chad
http://www.postgresqlforums.com/

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Negandhi, Nishith 2007-01-19 01:18:05 Error in trigger
Previous Message Negandhi, Nishith 2007-01-19 00:04:16 Re: System Date