Text Date format into datetime

  • Hey all,

    Due to an import from an external system i have a date in this format

    Tuesday, October 01 2013

    Wednesday, October 02 2013

    Thursday, October 03 2013

    Friday, November 01 2013

    Saturday, November 02 2013

    Sunday, November 10 2013

    Monday, November 11 2013

    Saturday, November 30 2013

    Sunday, December 01 2013

    Sunday, December 08 2013

    I need to turn this into a date data type.

    Now i cant think of any way other than what is the quite complex way of stripping off the day then casing the month to get the number, then rearranging the dd yyyy parts to make a date.

    Seems like there should be an easier way. Am I missing something? Is there any easy way to do this?

    Dan

  • Sorry please ignore the post. I managed to find a solution. Once you trim off the day the rest will just convert.

    Clever SQL!

    So just incase anyone finds this - i found this to be the answer

    CAST(SUBSTRING([DATEFIELD], CHARINDEX(',', [DATEFIELD]) + 2, 1000) AS DATETIME)

Viewing 2 posts - 1 through 1 (of 1 total)

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