Invalid date format entry

  • 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]

    :unsure:

  • 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)

  • 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.

  • Hi,

    Thanks a lot.

    It will work.

    I let you know exactly.

    [font="Verdana"]Regards
    Kumar Harsh[/font]

    :unsure:

  • 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?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply