开发者

Trying to convert a string to date time format in vb.net 2005

开发者 https://www.devze.com 2023-01-24 09:06 出处:网络
I can\'t seem to be able to convert a string that contains date value of \"100714 0700\" (2010-07-14 7am) to a date format in vb.net 2005

I can't seem to be able to convert a string that contains date value of "100714 0700" (2010-07-14 7am) to a date format in vb.net 2005

When I attempt to do:

        Dim provider As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture
        strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yym开发者_如何学Cmdd", provider)  

I get back "1/14/2010 12:07:00 AM"

How can I get a value of "2010-07-14 7:00" ?


Here is another link from here on SO that shows how to do this in C#

Convert String to Date in .NET if my incoming date format is in YYYYMMDD

In your case you probably also want add the time format:

  string s = "100714 0700";
  DateTime d = DateTime.ParseExact(s, "yyMMdd hhmm", CultureInfo.InvariantCulture);


Sorry, I read the question to quickly last time, hmmm have you tried something like strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yy" & "-" & "-" & "mm" & "-" & "dd", provider)

0

精彩评论

暂无评论...
验证码 换一张
取 消