我试图从 DateTime 值中获取数字月份作为字符串,而不是获取 MonthName、dayOfMonth。这是我的代码:
string columnDate = "7/1/2003 12:00:00 AM";
string datePart = "M";
DateTime newDate = DateTime.Parse(columnDate); // 7/1/2003 12:00:00 AM as date
dateToReturn = newDate.ToString(datePart);
// dateToReturn is set to "July 01". It's supposed to be "7"
我究竟做错了什么?