Link to home
Start Free TrialLog in
Avatar of dba123
dba123

asked on

System.DateTime.Now.Day.ToString("DD")

System.DateTime.Now.Day.ToString("DD") is not working.  I want to return 03, no 3 for day 3
Avatar of cubixSoftware
cubixSoftware

Try

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

HTH :)
Avatar of Mikal613
try lower case "dd"
Avatar of dba123

ASKER

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")
Avatar of dba123

ASKER

why can't I do it as I did the month?
Avatar of dba123

ASKER

System.DateTime.Now.ToString("MM") works
Avatar of dba123

ASKER

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")
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dim fun As Date
      fun = Now
      MsgBox(Format(fun, "dd"))
What AlexFM says works for me