Vchar to datetime

  • I would love a little help with converting the varchar to a datetime.

    The varchar data is in the format YYYYMMDDHHMMSS

    Andrew

  • Well, I got the date in...

    with SELECT Convert(VarChar(8), a.item)

  • Unfortunately, it's a little more complicated, since SQL Server doesn't have a valid dateformat like the one you need to use as an input...

    SELECT CAST(LEFT(@t,8) +' ' +SUBSTRING(@t,9,2)+':' +SUBSTRING(@t,11,2)+':' +SUBSTRING(@t,13,2) as DATETIME)



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Thanks...

    We just got it as well. Although we used convert. Thanks for the response. I am always impressed on this forum.

    Andrew

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

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