[ASP.NET]把日期字串yyyyMMdd轉成(或剖析成)DateTime型態

  • 3752
  • 0
  • 2018-04-19

[ASP.NET]把日期字串yyyyMMdd轉成(或剖析成)DateTime型態

c#

string strDateString = args[2];
                DateTime dateVar = DateTime.ParseExact(strDateString,
                                                    "yyyyMMdd",
                                                    System.Globalization.CultureInfo.InvariantCulture);

vb

Dim strDateString As String = args(2)
Dim dateVar As DateTime = DateTime.ParseExact(strDateString, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)

網路上參考來的,方便起見,我自己加入vb版本

How to convert date from yyyyMMdd format to mm-dd-yyyy format