how to convert the string date format to datetime using Derived column

  • Hi All

    i have date format like this Sep 14 2015 10:14PM any idea to convert into datetime using derived column

  • A simple CAST seems to work.

    (DT_DATE)"Sep 14 2015 10:14PM"

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • that ok fine .. thank you

  • any idea how to convert this format "Sep 21 2015 12:00:00:000AM"

  • Do you seriously have the dates stored as strings like that? Or that's the display used? Dates should be treated as dates. SSIS can identify a date/time value in the source and translate it automatically to the date/time value needed in the destination. No need to handle them as strings.

    If the string is really in there, you can use SUBSTRING

    (DT_DBTIMESTAMP)(SUBSTRING( "Sep 21 2015 12:00:00:000AM", 1, 20 ) + SUBSTRING( "Sep 21 2015 12:00:00:000AM", 25, 2 ))

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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