converting date time to a character

  • i have to import some tax data everymonth and in the past the date time data in one of the files looked like

    20070101

    this month they changed it to 01/01/2007 format. unfortunately the column in the table is a varchar(8) to handle the old data.

    is there any way to transform this without changing the table?

  • Is the date sent to you as text?

    If so, and it always has the format MM/DD/YYYY you could do something like this:

    select right(datefield,4)+left(datefield,2)+substring(datefield,4,2)



    Michelle

  • thx, i'll try that if need be

    for now we just changed it to varchar(10) and told our devs and billing people to check it and make sure it's OK. will have to wait and see what they say.

  • It is a bad design to store a date in a non-datetime column.

    If you are going to change it to anything, change it to a data type of datetime.

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

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