閱讀877 返回首頁    go 微軟 go windows


C#返回以數字日期編號為日期函數

/// <summary>
/// 返回以數字日期編號為日期函數
/// </summary>    
/// <returns>日期編號</returns>
public DateTime GetCodeToDate(string MyDateCode)
{
    try // 正常運行
    {
        String strYear = MyDateCode.Substring(0, 4);
        String strMonth = MyDateCode.Substring(4, 2);
        String strDay = MyDateCode.Substring(6, 2);
        // 返回日期
        return Convert.ToDateTime(strYear.ToString() + "-" + strMonth.ToString() + "-" + strDay.ToString());
    }
    catch (System.Exception Exp) // 異常處理
    {
        // 異常信息
        System.Diagnostics.Debug.Write(Exp.Message.ToString());
        // 返回日期
        return DateTime.Today;
    }
}

我有幾張阿裏雲幸運券分享給你,用券購買或者升級阿裏雲相應產品會有特惠驚喜哦!把想要買的產品的幸運券都領走吧!快下手,馬上就要搶光了。
https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=6evata1e&utm_source=6evata1e

最後更新:2017-10-08 21:03:02

  上一篇:go 圖說一周財經大事:雲棲大會召開 上市公司三季報啟幕
  下一篇:go  【文檔】四、Mysql Binlog事件含義詳解