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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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

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-

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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
it_saigeDeveloperCommented:
Is this in a windows form or on a website?

-saige-
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
RIASAuthor Commented:
Need a textbox to enter date in format MM/YY
it_saigeDeveloperCommented:
Quite simple.  I'll post a solution on your other question.

-saige-
RIASAuthor Commented:
Cheers mate!
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.  :)
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.