vb.net script ssis

the following code outputs the date as 021011 i need to change it to YYYYMMDD.

Thanks.
Dim sqlResult As OleDbDataReader
        sqlResult = sqlCommand.ExecuteReader()
        While sqlResult.Read()
            myYear = CStr(Year(sqlResult.GetDateTime(0))).Substring(2, 2)
            If Month(sqlResult.GetDateTime(0)) < 10 Then
                myMonth = "0" + CStr(Month(sqlResult.GetDateTime(0)))
            Else
                myMonth = CStr(Month(sqlResult.GetDateTime(0)))
            End If
            If Day(sqlResult.GetDateTime(0)) < 10 Then
                myDay = "0" + CStr(Day(sqlResult.GetDateTime(0)))
            Else
                myDay = CStr(Day(sqlResult.GetDateTime(0)))
            End If

            myDate = myDay + myMonth + myYear

Open in new window

aneilgAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Change following

myDate = myDay + myMonth + myYear

to

myDate = myYear + myMonth + myDay
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CodeCruiserCommented:
Sorry it would be

myDate = "20" + myYear + myMonth + myDay
0
aneilgAuthor Commented:
my fault sorry. the date gets generated randomly everyday. At present the out is MMDDYY. I need the output to be YYYYMMDD.



Thanks.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

CodeCruiserCommented:
Where is it being generated? Did you try the above?

You can also do

DateTime.ToString("yyyyMMdd")
0
aneilgAuthor Commented:
no tcomplete
0
CodeCruiserCommented:
What else did you want?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.