Re: [SQL] Create Datefield from 3 fields

2010-10-06 Thread Andreas Forø Tollefsen
Excellent. I did not see that.

Thank you

2010/10/6 Thomas Kellerer 

> Andreas Forø Tollefsen, 06.10.2010 13:11:
>
>  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,
>> '-MM-DD') FROM cshapes
>>
>
> You are missing the dashes in the input string that you specify in the
> format mask
>
>
>  to_date(gwsyear::text ||'-'|| gwsmonth::text ||'-'|| gwsday::text,
> '-MM-DD')
>
>
> Thomas
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


Re: [SQL] Create Datefield from 3 fields

2010-10-06 Thread Thomas Kellerer

Andreas Forø Tollefsen, 06.10.2010 13:11:

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, '-MM-DD') 
FROM cshapes


You are missing the dashes in the input string that you specify in the format 
mask

  to_date(gwsyear::text ||'-'|| gwsmonth::text ||'-'|| gwsday::text, 
'-MM-DD')


Thomas


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Create Datefield from 3 fields

2010-10-06 Thread Andreas Forø Tollefsen
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,
'-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?