這是一個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