How to convert varchar to datetime

  • Hi all

    I have a one table with two columns

    Column Name -- DataType

    StartDate -- varchar(128)

    NewStartDate -- DateTime

    the values in the startdate column is

    20080314

    20080319

    20080409T095627.115 GMT

    20080409T100238.767 GMT

    now i want to insert that values into newstartdate column

    so i request to all please help me

  • You may try something like below:

    SELECT CAST(SUBSTRING('20080314',5,2)+'/'+SUBSTRING('20080314',7,2)+'/'+SUBSTRING('20080314',1,4) AS DATETIME)

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

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