Create Datefield from 3 fields

From: Andreas Forø Tollefsen <andreasft(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Create Datefield from 3 fields
Date: 2010-10-06 11:11:04
Message-ID: AANLkTimswkQCUiZMT4EGkE-w5XKv5mgd3RcfdnT-N8QF@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi.

I am trying to create a datefield using YEAR, MONTH and DAY fields of type
integer.
I tried this query, but it did not give good results:
select to_date(gwsyear::text || gwsmonth::text || gwsday::text,
'YYYY-MM-DD') FROM cshapes
"1966526-01-01"
"7991903-12-13"
"1962831-01-01"
"194611-01-01"
"196211-01-01"

Any ideas on how to do this?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2010-10-06 11:36:16 Re: Create Datefield from 3 fields
Previous Message Ozer, Pam 2010-10-04 15:40:43 Re: Random sort with distinct