date to number conversion [message #454572] |
Thu, 06 May 2010 05:46  |
rajasekhar857
Messages: 500 Registered: December 2008
|
Senior Member |
|
|
Hi,
I want to change a table datatype from date to number where already
existing data should get convert.any possibilty of doing where i tried like this but no get changing.Even as Julian format is helping a bit i want the data to come as GMT formatl
Scenarios where i tried are like this.
ALTER TABLE Contacts ADD ALERT_DATE1 NUMBER(20,0)
/
UPDATE Contacts SET ALERT_DATE1 = TO_NUMBER(ALERT_DATE)
/
ALTER TABLE Contacts DROP COLUMN ALERT_DATE
/
ALTER TABLE Contacts RENAME COLUMN ALERT_DATE1 TO ALERT_DATE
/
but second statement failing.
Julian fomat like
SELECT sysdate,
TO_CHAR(sysdate, 'J'),
TO_DATE(TO_CHAR(sysdate, 'J'),'J')
FROM dual;
any suggestions will be highly appreciated.
Thanks,
Rajasekhar
|
|
|
|
|
|
Re: date to number conversion [message #454577 is a reply to message #454572] |
Thu, 06 May 2010 06:01   |
cookiemonster
Messages: 13966 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Not that I can think of.
Obvious question is why do you want to use a number column at all?
Especially since you don't appear to know what you want to store in it.
|
|
|
|
Re: date to number conversion [message #454580 is a reply to message #454579] |
Thu, 06 May 2010 06:08   |
rajasekhar857
Messages: 500 Registered: December 2008
|
Senior Member |
|
|
I will try accordingly to yours but the requirement came like that where i tried but it failed.so i replied here for getting any suggestions in it.Anyway i got more valuable information in this regard,
Thank you.
|
|
|
|
Re: date to number conversion [message #454582 is a reply to message #454572] |
Thu, 06 May 2010 06:11   |
cookiemonster
Messages: 13966 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
If you want to spend lots of time fixing bugs and dodgy data then you can try storing the date as a number.
But I really strongly advise that you leave it as a date.
|
|
|
|
|