Coverting char field to datetime

  • Can anyone help me create a Script to covert a char field that has this: "41CP52RBILL AD00043310 2003-07-032Ingenium" to a datetime "2003-07-03"? I need to covert this field to a Datetime so I can compare it with the current and delete the old records. Thanks for your help.

  • hi,

    for a quick, one off update you could try the following :-

    select substring("41CP52RBILL AD00043310 2003-07-032Ingenium", charindex("-", "41CP52RBILL AD00043310 2003-07-032Ingenium",0) -4 ,10)

    (replacing the values in quotes with your field name)

    this finds the first - and then removes 4 from the count (to take into account the year) and then just gets the next 10 chars.

    You'll need to convert it to a datetime with the required style.

    Paul

  • You da Man.. thanks very much..

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

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