I have a textbox for a date value which I retrieve as
Dim myDate as string = txtDate.Text.Trim
the value is in a dd/MM/yyyy format. e.g. 16/02/2012
of course for single digits, this could also be 1/2/2012
I have, in my web.config;
<globalization uiCulture="en-GB" culture="en-GB"/>
Then I use,
Dim newDate As Date = Date.ParseExact(adate, "dd/MM/yyyy", Nothing)
which produces "String was not recognized as a valid DateTime." error
I have also tried the following with no luck!:
a)
Dim newDate As DateTime = DateTime.ParseExact(adate, "dd/MM/yyyy", Nothing)
b)
Dim format() = {"dd/MM/yyyy", "d/M/yyyy", "dd-MM-yyyy"}
Dim newDate as Date = Date.ParseExact("16/02/2012", format, nothing)
for this specific one, I also tried specifiying culture-specific format information and formatting style instead of nothing above..
Any ideas? I have run out of mine….
I use
Please let me know if it worked or not.