pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lynch@lscorp.com
To: pgsql-sql@postgresql.org
Subject: cast text as date
Date: Tue, 16 Jun 1998 03:14:56 -0500
Message-ID: <v02140b24b1ab8fc52a9f@[207.152.64.133]> (raw)

I'm probably an idiot, but I can't find a way in the docs or archives to
cast from text to date.  The text field in question looks like a date, and
I know there's a function to parse it 'cuz if it were in a table to be
imported using \copy it would work, but what that function would be called,
I'm failing to guess...  Does that make sense?

Here's the mess I've created:

I've got two tables that I need to "merge".  Both have mostly the same
fields but t1 has type 'text' on fields that are really, really dates, and
t1 has more rows than t2.  So I'm using:

insert into t2 select blah, blah, cast (blah as date) from t1 where not
exists (select id from t2 where t2.id = t1.id);

Maybe I'm just going about this all wrong...

I've never created a function of my own, and maybe that's the way to go,
but I'm not sure where to start...
The strings in question actually only have a month/year (no date), if that
matters (they're expirations)...
The resulting date can just default to 1 for the date.

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com





view thread (5+ messages)  latest in thread

Message-ID: <v02140b24b1ab8fc52a9f@[207.152.64.133]>
Permalink:  ../v02140b24b1ab8fc52a9f@%5B207.152.64.133%5D/
Also on:    postgresql.org/message-id/v02140b24b1ab8fc52a9f@[207.152.64.133]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: lynch@lscorp.com
  Subject: Re: cast text as date
  In-Reply-To: <v02140b24b1ab8fc52a9f@[207.152.64.133]>
  References: <v02140b24b1ab8fc52a9f@[207.152.64.133]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox