Help with converting varchar to datetime

  • I am inserting a few thousand rows using SSIS package reading from an Excel file. There is one particular column in Excel file that stores the date value in this manner - 15-Apr-09.

    I need help in converting this date value into this manner - 04/15/2009

    I tried writing a scalar defined function but had some issues while converting. Any kind of help will be the most appreciated.

    Thank you

    Sidhartha

  • Hello,

    I am not exactly sure where the issue is.

    I would expect you could import dates in the DD-MMM-YY format into a DateTime Column without problems.

    Once in a DateTime Column (or variable) you could use Convert to display in whichever format is necessary e.g.

    Declare @MyDate DateTime

    Select @MyDate = '15-Apr-09'

    Print Convert(VarChar(10), @MyDate, 101)

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

  • This solves my problem to a major extent. Thank you so much.

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

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