| From: | Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | help building datetime from varchars |
| Date: | 2004-04-28 02:15:45 |
| Message-ID: | 20040428130718.R51170-100000@storm.niwa.co.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hopefully someone can point me in the proper direction....
I have a table containg (amongst others) two varchar attrs date_s &
time_s.
They contain strings like:
date_s | time_s
------------+----------
01/10/1989 | 00:30:00
Can someone suggest an sql to turn these into a single datetime?
I have tried the following with results I don't understand:
env2003=# select date_s || time_s, to_timestamp(date_s || time_s,'DD/MM/YYYYHH:MM:SS') from event limit 1;
?column? | to_timestamp
--------------------+------------------------
01/10/198900:30:00 | 1991-06-05 00:00:00+12
(1 row)
env2003=# select date_s || ' ' || time_s, to_timestamp(date_s || ' ' || time_s,'DD/MM/YYYY HH:MM:SS') from event limit 1;
?column? | to_timestamp
---------------------+------------------------
01/10/1989 00:30:00 | 1991-06-05 00:00:00+12
(1 row)
Thanks,
Brent Wood
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul Tillotson | 2004-04-28 02:43:36 | Re: Question |
| Previous Message | Tom Lane | 2004-04-28 02:07:00 | Re: linked list rewrite |