Re: Issue with to_timestamp function

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Lou Oquin <LOquin(at)nammotalley(dot)com>, Jerry Sievers <gsievers19(at)comcast(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Issue with to_timestamp function
Date: 2014-09-09 16:46:04
Message-ID: 540F2ECC.1080800@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/08/2014 04:18 PM, Lou Oquin wrote:
> Jerry;
>
> When I run the query you supplied, with my database
>
> select sli.ts::timestamptz as tstamp
> from public.sql_log_import sli
> where sli.id <= 10;
>
> I get the following error:
> ERROR: invalid input syntax for type timestamp with time zone: "08/06/2014 03:08:58"

Aah, just realized something. When you run the query I sent in my last
post I bet you will find the values in sli.ts where entered with double
quotes:

"08/06/2014 03:08:58"

So:

test=> create table ts_test (fld_1 text);
CREATE TABLE

test=> insert into ts_test values ('"08/06/2014 03:08:58"');
INSERT 0 1

test=> select * from ts_test ;

fld_1

-----------------------

"08/06/2014 03:08:58"

(1 row)


test=> select fld_1::timestamptz from ts_test ;

ERROR: invalid input syntax for type timestamp with time zone:
""08/06/2014 03:08:58""

>
> ********** Error **********
>
> ERROR: invalid input syntax for type timestamp with time zone: "08/06/2014 03:08:58"
> SQL state: 22007
>
> Thanks
>
> Lou
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lou Oquin 2014-09-09 17:07:37 Re: Issue with to_timestamp function
Previous Message Merlin Moncure 2014-09-09 16:42:23 Re: Convincing STABLE functions to run once