Im desperately trying to convert the following String to a Date.
I did research on how to do this, but was not able to do it successfully.
So basically, I have two Datepicker-Controls on my form.
When the form is being saved, I always want to have the Date from Control #1, but keep the Time from Control #2.
I am trying as following:
Dim strDatum As String = dtpDatum.Value.ToString() '= 03.01.13 00:00:00
Dim strStart As String = dtpVon.Value.ToString() '= 23.01.13 10:39:01
Dim sStartDatum = Strings.Left(strDatum, 8) & " " & Strings.Mid(strStart, 10, 9) '= 03.01.13 10:39:01
'here I'm trying to convert my new String to a Date and assign it to my a parameter
.Parameters("@dStartZeit").Value = DateTime.ParseExact(sStartDatum, "DD.MM.YY HH:mm:ss", New Globalization.CultureInfo("en-US"))
I get an “FormatException” when executing my query.
What am I doing wrong here?
Thanks!
Custom format strings are case-sensitive. Try: