convert a custom format string back to datetime

L

Lynn

Hi All,
We all know we can use
toString(strFormat) mothod to convert a datetime variable to a custom
string, let say strFormat = "YYYY!MM*DD", then we can get '2004!09*18', how
can I get convert the string back to datetime based on the specific format
'YYYY!MM*DD'.

Convert.todatetime method seems does not work.


Thanks a lot.


Lynn
 
J

Jonathan Allen

Dim d As Date = #9/18/2004#
Dim s As String
s = d.ToString("yyyy!MM*dd")
Console.WriteLine(s)
Dim d2 As Date
d2 = Date.ParseExact(s, "yyyy!MM*dd", New
System.Globalization.DateTimeFormatInfo)
Console.WriteLine(d2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top