I have problem with date and time formation, I need to get from this “12.11.2005 17:15:46” to this “121105_171546”.
I have write code and its working fine but there are too many variables and there is a problem, if the date is “4.8.2005 6:23:12”, final results are bad.
Does anyone have known how to solve this?
I have write code and its working fine but there are too many variables and there is a problem, if the date is “4.8.2005 6:23:12”, final results are bad.
Does anyone have known how to solve this?
VB.NET:
Dim sDate As String = "12.11.2005 17:15:46"
Dim var1 As String = Microsoft.VisualBasic.Left$(sDate, 2)
Dim var2 As String = Microsoft.VisualBasic.Left$(Microsoft.VisualBasic.Mid$(sDate, 4), 2)
Dim var3 As String = Microsoft.VisualBasic.Left$(Microsoft.VisualBasic.Mid$(sDate, 9), 2)
Dim var4 As String = Microsoft.VisualBasic.Left$(Microsoft.VisualBasic.Mid$(sDate, 12), 2)
Dim var5 As String = Microsoft.VisualBasic.Left$(Microsoft.VisualBasic.Mid$(sDate, 15), 2)
Dim var6 As String = Microsoft.VisualBasic.Right$(sDate, 2)
Label1.Text = var1 & var2 & var3 & "_" & var4 & var5 & var6