Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help with converting varchar to datetime Expand / Collapse
Author
Message
Posted Sunday, May 3, 2009 9:50 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 10, 2009 9:50 PM
Points: 3, Visits: 14
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
Post #709162
Posted Sunday, May 3, 2009 11:25 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 6:56 AM
Points: 1,330, Visits: 1,434
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
Post #709179
Posted Monday, May 4, 2009 12:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 10, 2009 9:50 PM
Points: 3, Visits: 14
This solves my problem to a major extent. Thank you so much.
Post #709203
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse