Get date in "YY" format

Hello,
Any suggestions on how to get date in "YY" format in vb.net
example the current year is "15"

Cheers
RIASAsked:
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.

Steven CarnahanNetwork ManagerCommented:
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("yy"));

Open in new window

0
it_saigeDeveloperCommented:
Simple enough, just use the ToString() method with the appropriate format on the date; e.g. -
Module Module1
	Sub Main()
		Dim [now] As DateTime = DateTime.Now
		For i As Integer = 0 To 20
			Console.WriteLine([now].AddYears(i).ToString("yy"))
		Next
		Console.ReadLine()
	End Sub
End Module

Open in new window

Which produces the following output -Capture.JPGYou can go refer to here for more formats - https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx

-saige-
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
RIASAuthor Commented:
Hello pony10us,

Can u suggest on how to find the date has expire depending on the month and year selected by combobox

Cheers
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

RIASAuthor Commented:
it_saige,
I am struggling on how to find the date has expire depending on the month and year selected by combobox

Cheers
0
it_saigeDeveloperCommented:
Is this in a windows form or on a website?

-saige-
0
RIASAuthor Commented:
It is windows form
Need to
*.      Accept expiry date in the format of MM / YY
*.      Validate that the expiry date is valid
a.      Must not be more than 20 years in the future
b.      Must not expire today or in the past

Cheers
0
RIASAuthor Commented:
Need a textbox to enter date in format MM/YY
0
it_saigeDeveloperCommented:
Quite simple.  I'll post a solution on your other question.

-saige-
0
RIASAuthor Commented:
Cheers mate!
0
Steven CarnahanNetwork ManagerCommented:
Thanks for jumping in Saige.  I got pulled away on a printer issue.  Looks like you were better able to help here anyway.  :)
1
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.