Re: Migration from DB2 to PostgreSQL-TIMESTAMP(arg1,arg1)

From: Daniel Cristian Cruz <danielcristian(at)gmail(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Migration from DB2 to PostgreSQL-TIMESTAMP(arg1,arg1)
Date: 2013-06-27 12:11:39
Message-ID: CACffM9GNwB-_YQguGW=O1-32oBUfRg=roxGaGRtFKG8cmrdQgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've done something weird:

CREATE OR REPLACE FUNCTION "timestamp"(_date date, _time time) RETURNS
timestamp AS $$
SELECT _date + _time;
$$ LANGUAGE sql;

SELECT "timestamp"('2013-01-01'::date, '12:00:00'::time);

It worked, but you will need explict cast and quote the timestamp function
name... Many people would not like this.

2013/6/27 Raymond O'Donnell <rod(at)iol(dot)ie>

> On 27/06/2013 12:51, sachin kotwal wrote:
> > I have done some more try as follows:
> >
> > #select timestamp(current_date);
> > ERROR: syntax error at or near "current_date" at character 18
> > STATEMENT: select timestamp(current_date);
> > ERROR: syntax error at or near "current_date"
> > LINE 1: select timestamp(current_date);
> > ======================================================
>
> If you're trying to convert a string to a timestamp as in your first
> email, you probably want to_timestamp():
>
> http://www.postgresql.org/docs/9.2/static/functions-formatting.html
>
> Otherwise, current_timestamp and friends produce the current date & time:
>
> http://www.postgresql.org/docs/9.2/static/functions-datetime.html
>
> HTH,
>
> Ray.
>
>
>
> >
> > #SELECT TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'));
> > ERROR: syntax error at or near "to_date" at character 18
> > STATEMENT: SELECT TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'));
> > ERROR: syntax error at or near "to_date"
> > LINE 1: SELECT TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'));
> > ======================================================
> >
> > select timestamp(current_date,current_time);
> > ERROR: syntax error at or near "current_date" at character 18
> > STATEMENT: select timestamp(current_date,current_time);
> > ERROR: syntax error at or near "current_date"
> > LINE 1: select timestamp(current_date,current_time);
> > ======================================================
> >
> > #SELECT TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'),'17:15:43'::time);
> > ERROR: syntax error at or near "to_date" at character 18
> > STATEMENT: SELECT
> > TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'),'17:15:43'::time);
> > ERROR: syntax error at or near "to_date"
> > LINE 1: SELECT TIMESTAMP(to_date('2013-01-01','YYYY-MM-DD'),'17:15:4...
> >
> >
> >
> > --
> > View this message in context:
> http://postgresql.1045698.n5.nabble.com/Migration-from-DB2-to-PostgreSQL-TIMESTAMP-arg1-arg1-tp5761389p5761390.html
> > Sent from the PostgreSQL - general mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Raymond O'Donnell :: Galway :: Ireland
> rod(at)iol(dot)ie
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
Daniel Cristian Cruz
クルズ クリスチアン ダニエル

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Greco 2013-06-27 12:24:14 auto_explain & FDW
Previous Message Sandro Santilli 2013-06-27 11:58:16 Triggers NOT running as table owner