Using the following code:
var value = "12-1";
DateTime dateTime;
var canParse = DateTime.TryParse(value, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out dateTime);
The returned DateTime is the 1st of December of the current year.
The current culture of my machine is {en-AU}
and the date formats are set up for Australian formatted dates. When I hover over the CurrentCulture
I can see that it is set to the en-AU
culture.
I realise that the value is not a complete date but excel handles the same case. The TryParse method is returning a US formatted date when the date string is not fully specified.
Anything I can do?