Обсуждение: System Date

Поиск
Список
Период
Сортировка

System Date

От
"Negandhi, Nishith"
Дата:
Hi,
How to check the system date using PG/SQL ??

Re: System Date

От
"Benjamin Krajmalnik"
Дата:
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 Date

Hi,
How to check the system date using PG/SQL ??

Re: System Date

От
"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 .??
 
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 Date

Hi,
How to check the system date using PG/SQL ??

Re: System Date

От
"Chad Wagner"
Дата:
On 1/18/07, Negandhi, Nishith <Nishith.Negandhi@infousa.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/

Re: System Date

От
"Milen A. Radev"
Дата:
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