Обсуждение: System Date
Hi,
How to check the system date using PG/SQL ??
select CURRENT_TIMESTAMP
or
select LOCALTIMESTAMP
the first has the information with the timezone offset at the end, whereas the second does not.
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Negandhi, Nishith
Sent: Thursday, January 18, 2007 3:43 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] System DateHi,How to check the system date using PG/SQL ??
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';
'select now();'
LANGUAGE 'plpgsql';
However, I get the error:
ERROR: syntax error at or near "select" at character 51
Any suggestions .??
Thanks in advance
From: Benjamin Krajmalnik [mailto:kraj@illumen.com]
Sent: Thursday, January 18, 2007 5:31 PM
To: Negandhi, Nishith; pgsql-admin@postgresql.org
Subject: RE: [ADMIN] System Date
select CURRENT_TIMESTAMP
or
select LOCALTIMESTAMP
the first has the information with the timezone offset at the end, whereas the second does not.
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Negandhi, Nishith
Sent: Thursday, January 18, 2007 3:43 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] System DateHi,How to check the system date using PG/SQL ??
On 1/18/07, Negandhi, Nishith <Nishith.Negandhi@infousa.com> wrote:
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/
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 51Any 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/
Negandhi, Nishith написа: > 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 .?? > [...] CREATE FUNCTION "CreateDate"() RETURNS date AS 'select CURRENT_DATE;' LANGUAGE SQL; (more info here - http://www.postgresql.org/docs/current/static/xfunc-sql.html) Although I fail to see the usefulness of such a function. -- Milen A. Radev