Aug 10, 2004 #1 DerPflug Programmer Mar 28, 2002 153 US How can I convert a string from "08102004" to "08/10/2004")?
Aug 10, 2004 1 #2 PankajBanga Programmer Jun 11, 2003 389 AU one way could be: Dim str As String = "08102004" Dim dt As Date = New Date(str.Substring(4), str.Substring(2, 2), str.Substring(0, 2)) MessageBox.Show(dt) http://home.iprimus.com.au/pankajbanga Upvote 0 Downvote
one way could be: Dim str As String = "08102004" Dim dt As Date = New Date(str.Substring(4), str.Substring(2, 2), str.Substring(0, 2)) MessageBox.Show(dt) http://home.iprimus.com.au/pankajbanga
Aug 11, 2004 1 #3 ca8spo Programmer Aug 14, 2002 16 GB You could do this if you wanted it to use the same variable. Dim str As String = "08102004" str = str.Insert(2, "/").Insert(5, "/") Upvote 0 Downvote
You could do this if you wanted it to use the same variable. Dim str As String = "08102004" str = str.Insert(2, "/").Insert(5, "/")
Aug 18, 2004 #4 Spaniard MIS Jul 23, 2002 29 US PankajBanga, Your Solution is great! However, if one wanted to make 08 the month instead of 10, the following slight modification accomplishes it. Dim str As String = "08102004" Dim dt As Date = New Date(str.Substring(4), str.Substring(0, 2), str.Substring(2, 2)) MessageBox.Show(dt) Both solutions work well (ca8spo), depending on your needs. Stars to all! Upvote 0 Downvote
PankajBanga, Your Solution is great! However, if one wanted to make 08 the month instead of 10, the following slight modification accomplishes it. Dim str As String = "08102004" Dim dt As Date = New Date(str.Substring(4), str.Substring(0, 2), str.Substring(2, 2)) MessageBox.Show(dt) Both solutions work well (ca8spo), depending on your needs. Stars to all!
Aug 19, 2004 #5 MickTheBelgian Programmer Jan 11, 2001 160 DK If you use VB.NET, there is a function Date.Parse... Upvote 0 Downvote