convert string to date

  • Could anyone help me on how to convert a string such as 20080610014222 to a date format e.g 06/10/2008.

    Thanks in advance.

  • Being in QA or EM press {F1}, click on "Index" tab, type "CAST", hit Enter twice.

    Scroll to the table with date conversion styles.

    Pay special attention to the line with ISO format.

    This line has the answer you need.

    _____________
    Code for TallyGenerator

  • SET DATEFORMAT YMD

    declare @datestring varchar(20)

    set @datestring = '20080610014222'

    select cast(

    substring(@datestring, 1,4) + '/' +

    substring(@datestring, 5,2) + '/' +

    substring(@datestring, 7,2)

    as datetime)

    HTH

    Dave J

    PS. Why does Sergiy remind me of this? Or is it just me?

    A helicopter was flying around above Seattle yesterday when an electrical

    malfunction disabled all of aircraft's electronic navigation and communication

    equipment. Due to the clouds and haze the pilot could not determine his

    position or course to steer to the airport.The pilot saw a tall building,

    flew toward it, circled, drew a handwritten sign and held it in the

    helicopter's window. The sign said "WHERE AM I"? in large letters.

    People in the tall building quickly responded to the aircraft, drew a large

    sign an held it in a building window. The sign said, "YOU ARE IN A HELICOPTER".

    The pilot smiled, waved, looked at his map and determined the course to steer

    to SEATAC ( Seattle/Tacoma) airport and landed safely. After they were on the

    ground, the co-pilot asked the pilot how the "YOU ARE IN A HELICOPTER" sign helped

    determine their position. The pilot responded, "I knew that had to be the Microsoft

    building because they gave me a technically correct but completely useless answer".


    http://glossopian.co.uk/
    "I don't know what I don't know."

  • Go to Books Online, check "CONVERT". There are lots of time format.

  • David,

    I really liked the helicopter story. Well played!

    😎

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

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