Reputation: 33
I have a column having dates in varchar format, I want to convert it, to date
format, which I did through below query:
select to_date(EVENT_DT, 'YYYYMMDD') from demographic;
Now, I want to create a new column and populate the column with the values that I got from above query. I am not able to do it with alter table
.
Any solutions?
Upvotes: 0
Views: 53
Reputation: 56
Hope it works as @Mike Walton said
Alter table demographic add Converted_date date;
----ms sql server
Update demographic set Converted_date = convert(date, EVENT_DT , 101);
---or using to_date
Update demographic set Converted_date = to_date(EVENT_DT, 'YYYYMMDD');
Upvotes: 3