[Fwd: help building datetime from varchars]

From: "Shane D(dot)" <shane(dot)dawalt(at)wright(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: [Fwd: help building datetime from varchars]
Date: 2004-05-04 13:01:57
Message-ID: 40979445.3030605@wright.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I have tried contacting the list owner, but nobody responds so I am
knowingly sending administrative mail to the list. Sorry folks.

For months, particularly since February, I have been receiving e-mail
that is out-of-date. Since they are relatively old (weeks to months) I
cannot say whether or not they are duplicates. A copy of such an e-mail
I just received this morning is attached along its headers. Note that
postgresql.org received it on 27 Apr and that it was relayed to my mail
server within the last 24 hours (May 3 at 11:54pm GMT-4 to be exact).
Why does this happen and can't it be made to stop? (And I'm not picking
on Brent. His is just one of 8 messages I received this morning from
the month of April.)

Shane

-------- Original Message --------
Return-path:
<pgsql-general-owner+M60495=shane(dot)dawalt=wright(dot)edu(at)postgresql(dot)org>
Received: from conversion-daemon.sms1.wright.edu by sms1.wright.edu
(iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) id
<0HX600C01AXW17(at)sms1(dot)wright(dot)edu> for shane(dot)dawalt(at)wright(dot)edu; Tue, 04
May 2004 00:55:40 -0400 (EDT)
Received: from avs1.wright.edu (avs1.wright.edu [130.108.128.93]) by
sms1.wright.edu (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8
2003)) with ESMTP id <0HX600NSNB0S2W(at)sms1(dot)wright(dot)edu> for
shane(dot)dawalt(at)wright(dot)edu; Tue, 04 May 2004 00:55:40 -0400 (EDT)
Received: from CONVERSION-DAEMON.avs1.wright.edu by avs1.wright.edu
(PMDF V6.2-X27 #30758) id <0HX600J01B0S8Q(at)avs1(dot)wright(dot)edu> for
shane(dot)dawalt(at)wright(dot)edu; Tue, 04 May 2004 00:55:40 -0400 (EDT)
Received: from zippy.ims.net (zippy.ims.net [208.166.202.2]) by
avs1.wright.edu (PMDF V6.2-X27 #30758) with ESMTP id
<0HX600E7XB0SPC(at)avs1(dot)wright(dot)edu> for shane(dot)dawalt(at)wright(dot)edu; Tue, 04
May 2004 00:55:40 -0400 (EDT)
Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) by
zippy.ims.net (8.11.6/linuxconf) with ESMTP id i444s9B02154 for
<shane(dot)dawalt(at)wright(dot)edu>; Mon, 03 May 2004 23:54:22 -0500
Received: from localhost (unknown [200.46.204.2]) by
svr1.postgresql.org (Postfix) with ESMTP id 49B76D1B50C for
<pgsql-general-postgresql(dot)org(at)localhost(dot)postgresql(dot)org>; Tue, 27 Apr
2004 23:15:48 -0300 (ADT)
Received: from svr1.postgresql.org ([200.46.204.71]) by localhost
(neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id
25085-03 for <pgsql-general-postgresql(dot)org(at)localhost(dot)postgresql(dot)org>;
Tue, 27 Apr 2004 23:15:50 -0300 (ADT)
Received: from clam.niwa.co.nz (clam.niwa.cri.nz [202.36.29.1]) by
svr1.postgresql.org (Postfix) with ESMTP id BFB03D1B448 for
<pgsql-general(at)postgresql(dot)org>; Tue, 27 Apr 2004 23:15:43 -0300 (ADT)
Received: from storm.niwa.co.nz (storm.niwa.co.nz [192.168.59.10]) by
clam.niwa.co.nz (8.12.3p3/8.12.3) with ESMTP id i3S2FjSb092102 for
<pgsql-general(at)postgresql(dot)org>; Wed, 28 Apr 2004 14:15:46 +1200 (NZST
envelope-from b(dot)wood(at)niwa(dot)co(dot)nz)
Received: from localhost (woodb(at)localhost) by storm.niwa.co.nz
(8.11.6/8.11.6) with ESMTP id i3S2Fjc55463 for
<pgsql-general(at)postgresql(dot)org>; Wed, 28 Apr 2004 14:15:45 +1200
Date: Wed, 28 Apr 2004 14:15:45 +1200 (NZST)
From: Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz>
Subject: [GENERAL] help building datetime from varchars
In-reply-to: <Pine(dot)LNX(dot)4(dot)44(dot)0404280159270(dot)18160-100000(at)emo(dot)org(dot)tr>
Sender: pgsql-general-owner(at)postgresql(dot)org
To: pgsql-general(at)postgresql(dot)org
Message-id: <20040428130718(dot)R51170-100000(at)storm(dot)niwa(dot)co(dot)nz>
MIME-version: 1.0
Content-type: TEXT/PLAIN; charset=US-ASCII
Precedence: bulk
X-Original-To: pgsql-general-postgresql(dot)org(at)localhost(dot)postgresql(dot)org
X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang)
X-Virus-Scanned: by amavisd-new at postgresql.org
X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=
X-Spam-Level:
X-Mailing-List: pgsql-general
Original-recipient: rfc822;shane(dot)dawalt(at)wright(dot)edu

Hopefully someone can point me in the proper direction....

I have a table containg (amongst others) two varchar attrs date_s &
time_s.

They contain strings like:

date_s | time_s
------------+----------
01/10/1989 | 00:30:00

Can someone suggest an sql to turn these into a single datetime?

I have tried the following with results I don't understand:

env2003=# select date_s || time_s, to_timestamp(date_s || time_s,'DD/MM/YYYYHH:MM:SS') from event limit 1;
?column? | to_timestamp
--------------------+------------------------
01/10/198900:30:00 | 1991-06-05 00:00:00+12
(1 row)

env2003=# select date_s || ' ' || time_s, to_timestamp(date_s || ' ' || time_s,'DD/MM/YYYY HH:MM:SS') from event limit 1;
?column? | to_timestamp
---------------------+------------------------
01/10/1989 00:30:00 | 1991-06-05 00:00:00+12
(1 row)

Thanks,

Brent Wood

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Responses

Browse pgsql-general by date

  From Date Subject
Next Message phantom 2004-05-04 13:58:36 Postgres to oracle data migration
Previous Message Tom Lane 2004-05-04 12:19:14 Re: BUG ? or SQL miss understanding ?