Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > changing column...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 3098 of 3323
Post > Topic >>

changing column datatype from char(20) to timestamp

by netllama@[EMAIL PROTECTED] ("Lonni J Friedman") Apr 29, 2008 at 10:12 AM

Greetings,
This is a followup to an issue that I had about 9 months ago:
http://archives.postgresql.org/pgsql-novice/2007-08/msg00067.php

Back then, I was effectively mangling timestamps in a table, by
casting to char(20) to work around problem with a webapp.  The app
finally got fixed, and I'm looking into how to try to get all this
ugly data from char(20) into a sane 'timestamp without time zone'
format.  Right now, its all:

date_created   | character(20) | not null

I want to change it to:
date_created   | timestamp without time zone | not null

Unfortunately, I can't just do:
ALTER TABLE data ALTER COLUMN date_created TYPE timestamp ;

since the data is currently in this format:
04-29-2008 10:03:28

since, its getting inserted via a query like this:
INSERT INTO data (date_created) VALUES ((select
to_char(current_timestamp, 'MM-DD-YYYY HH24:MI:SS')) ;

Surely there must be a way to fix this without having to dump the
data, fix the format, and reinsert it ?

thanks

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman netllama@[EMAIL PROTECTED]
 https://netllama.linux-sxs.org

-- 
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 4 Posts in Topic:
changing column datatype from char(20) to timestamp
netllama@[EMAIL PROTECTED  2008-04-29 10:12:20 
Re: changing column datatype from char(20) to timestamp
tgl@[EMAIL PROTECTED] (T  2008-04-29 13:46:23 
Re: changing column datatype from char(20) to timestamp
sszabo@[EMAIL PROTECTED]   2008-04-29 10:46:45 
Re: changing column datatype from char(20) to timestamp
netllama@[EMAIL PROTECTED  2008-04-29 13:26:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 6:10:32 CST 2008.