日期:2014-05-18  浏览次数:20986 次

求实现一个简单的功能,急!
我想将一个数据库里的字符串 "20070919111816 ",用C#里的format函数在报表里输出转换为: "2007-09-19   11:18:16 "   要能怎么做?

谢谢!!!!

------解决方案--------------------
参考这个帖子

http://community.csdn.net/Expert/topic/5731/5731819.xml?temp=.4787561
------解决方案--------------------
Dim str As String = DateTime.ParseExact( "20070919111816 ", "yyyyMMddHHmmss ", Nothing).ToString( "yyyy/MM/dd HH:mm:ss ")
------解决方案--------------------
vb中
Dim str As String = DateTime.ParseExact( "20070919111816 ", "yyyyMMddHHmmss ", Nothing).ToString( "yyyy-MM-dd HH:mm:ss ")
------解决方案--------------------
DateTime ddate = DateTime.ParseExact( "20070919111816 ", "yyyy-MM-dd HH:mm:ss ", System.Globalization.DateTimeFormatInfo.InvariantInfo);
------解决方案--------------------
DateTime ddate = DateTime.ParseExact( "20070919111816 ", "yyyyMMddHHmmss ", System.Globalization.DateTimeFormatInfo.InvariantInfo);


------解决方案--------------------
DateTime ddate = DateTime.ParseExact( "20070919111816 ", "yyyy-MM-dd HH:mm:ss ", System.Globalization.DateTimeFormatInfo.InvariantInfo);
------解决方案--------------------

"20070919111816 ".insert(12, ": ").insert(10, ": ").insert(8, " ").insert(6, "- ").insert(4, "- ");