Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help with converting varchar to datetime


Help with converting varchar to datetime

Author
Message
sidhartha.pooboni
sidhartha.pooboni
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
John H Marsh
John H Marsh
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1489 Visits: 1455
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
sidhartha.pooboni
sidhartha.pooboni
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 14
This solves my problem to a major extent. Thank you so much.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search