这是一个String日期:解析字符串日期以特定格式
dob = reader.GetValue(7).ToString();` return like "12/2/2012"
但我想转换为这种格式"2012212"
(它传递之前),我已经试过
string newDate = dob.ToString("yyyMMdd")
但我得到出现以下错误:
The best overloaded method match for 'string.ToString(System.IFormatProvider)has some invalid arguments
有什么想法吗?
为什么叫'ToString'在'reader.GetValue(7)'?为什么不把它转换为'DateTime'? –
,因为'dob'被声明为字符串。 –
reader.GetDateTime(7)返回DateTime对象吗? – DespeiL