Re: converting varchar date strings to date - Mailing list pgsql-general

From Richard Huxton
Subject Re: converting varchar date strings to date
Date
Msg-id 200310141830.11117.dev@archonet.com
Whole thread Raw
In response to converting varchar date strings to date  ("pw" <p.willis@telus.net>)
List pgsql-general
On Tuesday 14 October 2003 17:54, pw wrote:
> Hello,
>
> How can I typecast a date generated from VARCHAR fields into
> a date field
>
> ie:
>
> UPDATE inventory SET date_field = vc_year||'-'||vc_month||'-'||vc_day;

... SET date_field = CAST(vc_year...vc_day AS date)
or
... SET date_field = (vc_year...vc_day)::date

The first is SQL-standard, the second less typing.

If that gives you problems, cast to text first, then to date.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: How to list which tables are available?
Next
From: Ron Johnson
Date:
Subject: Re: How to list which tables are available?