I have a Web service that receives dates on this format dd/MM/yyyy.
I realized that it crash cause sometimes I have dates like this one 1/1/2012.
I have no control on what the web service receives.
I tried
myDate = cDate(myString)
myDate = Convert.toDatetime(myString)
myDate = DateTime.ParseExact(myString, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None)
myDate = Convert.ToDateTime(myString.ToString("dd/MM/yyyy"))
Nothing works, so is there any elegant way to do this or I have to split and add “0” when it’s a date like this
Thank you
This works:
It also works for “01/02/2012”, “21/1/2012”, “1/11/2012” and “12/12/2012”.