Re: Issue with to_timestamp function

From: Lou Oquin <LOquin(at)nammotalley(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Issue with to_timestamp function
Date: 2014-09-09 17:07:37
Message-ID: ED2FDA515391AF4C99E5C8847113CB7125CEEFC5@NAMEEX01.talleyds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for your help, Adrian.

Had a fire to put out before I left for home yesterday, and did not see the replies from you, Melvin Davidson and Jerry Sievers until this morning. I read the most recent (yours) first) and ran the query in psql; it complained about UTF8 encoding characters in the data. Then dug into the raw data and found there were three hi-bit characters in front of the '0' on the first record. Replaced the first records date with the second records 'identical' (but without the added characters) and the timestamp casting now works as expected.

Then, when I read Jerry's reply, saw that he had spotted it late yesterday afternoon.

It is a sql server log file that I'm importing into my local database; I'm using pg in analyzing the log data.

I apparently selected ascii instead of UTF8 encoding when I imported the sql server log file with pgadmin...

Thanks again.

Lou
-----Original Message-----
From: Adrian Klaver [mailto:adrian(dot)klaver(at)aklaver(dot)com]
Sent: Monday, September 08, 2014 6:04 PM
To: Lou Oquin; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Issue with to_timestamp function

On 09/08/2014 01:52 PM, Lou Oquin wrote:
> I've imported a csv export of an MS SQL Server log file into a staging
> table on my local install of Postgresql (9.3/UTF8 encoding) for analysis.
>

>
> select to_timestamp(ts, 'MM/DD/YYYY hh24:mi:ss')::timestamp with time
> zone as tStamp
>
> from sql_log_import
>
> where id <= 10
>
> ********** Error **********
>
> SQL state: 22007
>
> Detail: Value must be an integer.
>
> Any Ideas?

To get that error I had to do something like this:

hplc=> select to_timestamp('aug/06/2014 03:08:58 ', 'MM/DD/YYYY hh24:mi:ss');
ERROR: invalid value "au" for "MM"
DETAIL: Value must be an integer.

So at a guess, the data being imported has some month abbreviations in it.

>
> Thanks
>
> *Lou O'Quin*
>

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ellen 2014-09-09 18:42:31 Re: Pgpool starting problem
Previous Message Adrian Klaver 2014-09-09 16:46:04 Re: Issue with to_timestamp function