C# //将格式为yyyyMMdd的时间转化为yyyy-MM-dd类型 详例: string beginDate="20140224";
beginDate =DateTime.ParseExact(beginDate,"yyyyMMdd",CultureInfo.CurrentCulture).ToString( "yyyy-MM-dd");
//Server:如何将yyyymmddHHmmss转换为yyyy-MM-dd HH:mm:ss格式 详例: SELECT CAST(( CAST(CONVERT(DATE, LEFT(CONVERT(NVARCHAR(50), ISNULL(Memo9,
'19000101000000')),
8)) AS NVARCHAR(10))
+ ' '
+ SUBSTRING(CONVERT(NVARCHAR(50), ISNULL(Memo9,
'19000101000000')),
9, 2) + ':' + SUBSTRING(CONVERT(NVARCHAR(50), ISNULL(Memo9,
'19000101000000')),
11, 2) + ':'
+ SUBSTRING(CONVERT(NVARCHAR(50), ISNULL(Memo9,
'19000101000000')),
13, 2) ) AS DATETIME)
FROM Invoice; //将System.DateTime对象的值转换为文件时间 Datetime.Now.ToFileTime(); //将文件时间转换为System.DateTime对象 DateTime.FromFileTime();
|