System.DateTime.Now.Day.ToString("DD") is not working.  I want to return 03, no 3 for day 3
Who is Participating?

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

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.


MessageBox.Show(Format(Now.Day, "00"))

HTH :)
try lower case "dd"
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

dba123Author Commented:
for some reason, it's putting dd in the string such as 04dd for this:

System.DateTime.Now.ToString("MM") & System.DateTime.Now.Day.ToString("dd")

why is the month working but not the day in this case?
Dim MyDate As New DateTime(now)
Dim MyString As String = MyDate.ToString("dd")
dba123Author Commented:
why can't I do it as I did the month?
dba123Author Commented:
System.DateTime.Now.ToString("MM") works
dba123Author Commented:
Dim MyDate As New DateTime(now)

Error: Value of type 'Date' cannot be converted to 'Long'.

I'd still prefer to do it this way, just like I did for month: System.DateTime.Now.Day.ToString("dd")

should be:


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
Dim fun As Date
      fun = Now
      MsgBox(Format(fun, "dd"))
What AlexFM says works for me
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.