Very basic question regarding parsing date in F#. I am very new to F# and .NET, so please bear with me.
My date has the format yyyyMMDD
like 20100503
.
How do I parse this into a DateTime
type in F#.
I tried System.DateTime.Parse("20100503");
but get an error.
How do I pass a format string into the Parse method??
ANSWER is - Thanks everyone for the responses.
let d = System.DateTime.ParseExact("20100503", "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
You should be able to use a custom format string. Try this:
System.DateTime.ParseExact("20100503", "yyyymmdd", null);;
See http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx for more details.
DateTime.ParseExact("20100503", "yyyyMMdd", CultureInfo.CurrentCulture)
Use the ParseExact method and use lowercase d instead of upper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With