I have a datetime object (initialized), how can I output the month part as MM?
Asked
Active
Viewed 125 times
2 Answers
8
Your_Date_Time_Object.ToString("MM")

em70
- 6,088
- 6
- 48
- 80
-
You beat me to it. +1 for doing it in one line. – Kredns May 04 '09 at 21:50
0
DateTime date = DateTime.Now; // Use current date
string format = "MM"; // Use this format
Console.WriteLine(date.ToString(format)); // Write to console

Kredns
- 36,461
- 52
- 152
- 203