funky date/time stamp

  • Hi All,

    i have this funky date-time stamp being loaded into my database as a varchar 50. supposely it is coming in from reading the file's date/time stamp.

    any ideas how i can convert this data into something friendly and easy to work it.

    here are some examples:

    Tue Jun 12 21:00:53 EDT 2012

    Tue Jun 12 22:20:51 BST 2012

    Wed Jun 13 02:03:07 JST 2012

    Tue Jun 12 00:31:40 EDT 2012

    thanks!

  • SELECT CAST(SUBSTRING(Col, 5, 6) + ',' + RIGHT(Col, 4) + ' ' + SUBSTRING(Col, 12, 8) AS DATETIME)

    FROM

    (VALUES

    ('Tue Jun 12 21:00:53 EDT 2012'),

    ('Tue Jun 12 22:20:51 BST 2012'),

    ('Wed Jun 13 02:03:07 JST 2012'),

    ('Tue Jun 12 00:31:40 EDT 2012')) AS TVC(Col);

    Ignore the Values part, since you already have the data in a table. It's the Select part that matters.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • excellent! thank you! it was like the forest and the trees analogy.

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

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