August 22, 2009 at 3:29 am
Hi,
I have a date column(dob) which is varchar in sql server 2000.
By mistake the entry has been dd/mm/yyyy.
How do I correct it to mm/dd/yyyy.
Any solution.
Thanks.
[font="Verdana"]Regards
Kumar Harsh[/font]
August 22, 2009 at 4:24 am
hi,
its the varchar column so change& update with the substring
like
create table #temp
( slno int,
date1 varchar(15)
)
insert into #temp
select 1,'01/12/2008'
union all
select 2,'05/12/2008'
union all
select 3,'10/12/2008'
union all
select 4,'15/12/2008'
union all
select 5,'20/12/2008'
union all
select 6,'25/12/2008'
union all
select 7,'30/12/2008'
select slno,(substring(date1,4,2))+'/'+(left(date1,2))+'/'+ right(date1,4) from #temp
update #temp
set date1 = (substring(date1,4,2))+'/'+(left(date1,2))+'/'+ right(date1,4)
August 22, 2009 at 5:06 am
The script will work.....
Before running it though, have ALL dates been entered in the same format? If not, then running the script won't fix the problem.
August 22, 2009 at 6:27 am
Hi,
Thanks a lot.
It will work.
I let you know exactly.
[font="Verdana"]Regards
Kumar Harsh[/font]
August 24, 2009 at 7:04 am
I have to ask, why is it a varchar column if it only contains dates? Do you have the ability to change it to a datetime/smalldatatime column?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply