[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-04-03
11
Medium Priority
?
3,927 Views
Last Modified: 2008-01-09
System.DateTime.Now.Day.ToString("DD") is not working.  I want to return 03, no 3 for day 3
0
Comment
Question by:dba123
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 6

Expert Comment

by:cubixSoftware
ID: 16361717
Try

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

HTH :)
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 16361729
try lower case "dd"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:dba123
ID: 16361761
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?
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 16361774
Dim MyDate As New DateTime(now)
Dim MyString As String = MyDate.ToString("dd")
0
 
LVL 1

Author Comment

by:dba123
ID: 16361782
why can't I do it as I did the month?
0
 
LVL 1

Author Comment

by:dba123
ID: 16361785
System.DateTime.Now.ToString("MM") works
0
 
LVL 1

Author Comment

by:dba123
ID: 16361807
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")
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 16361810
System.DateTime.Now.Day.ToString("dd")

should be:

System.DateTime.Now.ToString("dd")

0
 
LVL 48

Expert Comment

by:Mikal613
ID: 16361823
Dim fun As Date
      fun = Now
      MsgBox(Format(fun, "dd"))
0
 
LVL 6

Expert Comment

by:cubixSoftware
ID: 16361921
What AlexFM says works for me
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question