pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCreate Datefield from 3 fields
3+ messages / 2 participants
[nested] [flat]
* Create Datefield from 3 fields
@ 2010-10-06 11:11 Andreas Forø Tollefsen <andreasft@gmail.com>
2010-10-06 11:36 ` Re: Create Datefield from 3 fields Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Forø Tollefsen @ 2010-10-06 11:11 UTC (permalink / raw)
To: 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?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create Datefield from 3 fields
2010-10-06 11:11 Create Datefield from 3 fields Andreas Forø Tollefsen <andreasft@gmail.com>
@ 2010-10-06 11:36 ` Thomas Kellerer <spam_eater@gmx.net>
2010-10-06 11:43 ` Re: Create Datefield from 3 fields Andreas Forø Tollefsen <andreasft@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Kellerer @ 2010-10-06 11:36 UTC (permalink / raw)
To: pgsql-sql
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, 'YYYY-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, 'YYYY-MM-DD')
Thomas
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create Datefield from 3 fields
2010-10-06 11:11 Create Datefield from 3 fields Andreas Forø Tollefsen <andreasft@gmail.com>
2010-10-06 11:36 ` Re: Create Datefield from 3 fields Thomas Kellerer <spam_eater@gmx.net>
@ 2010-10-06 11:43 ` Andreas Forø Tollefsen <andreasft@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Forø Tollefsen @ 2010-10-06 11:43 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-sql
Excellent. I did not see that.
Thank you
2010/10/6 Thomas Kellerer <spam_eater@gmx.net>
> 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,
>> 'YYYY-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,
> 'YYYY-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
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2010-10-06 11:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 11:11 Create Datefield from 3 fields Andreas Forø Tollefsen <andreasft@gmail.com>
2010-10-06 11:36 ` Thomas Kellerer <spam_eater@gmx.net>
2010-10-06 11:43 ` Andreas Forø Tollefsen <andreasft@gmail.com>
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