.NET Calendar - how to ensure two digits are always used for months and days

How do you make the .NET calendar always return  two digits for days and months.

For example.

I need to  format dates like this: mm/dd/yyyy

Jan must equal = 01
Feb = 02

Same with days  01, 02, .... 09...10

How to you ensure 2 digit's for months and days are displayed back to user?

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.

One simple solution is to add 100 to the number, convert to a string and take the right 2 characters.

Hokey, but it works.

String str = (num < 10 ? "0"+num : ""+num) ;
you can use ToString("MM/dd/yyyy")

for exaample, you have DateTimePicker1 control.


Please note that "MM" is in capital, not "mm"

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
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

From novice to tech pro — start learning today.