DateTime.ParseExact revisited

Hey Guys,
This has been beaten quite a bit but I am seeing the following using dateTime.parseexact function
when I use the following to convert string to date
DateTime.ParseExact(“10/09/2024”,“mm/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

I get the following response
01/09/2024 00:10:00

I am not adding the hh:mm format anywhere in conversion. You may notice that it tacked the 10-month to the minute section

Can u try your format like this? “MM/dd/yyyy”
time will be set as default: 00:00:00

MM = Month

Hi

The month need be MM

DateTime.ParseExact(“10/09/2024”,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

1 Like

Hi @Nick101

Try this:

DateTime.ParseExact("10/09/2024","MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture)

Hope it helps!!

1 Like

Thank you, obvious oversight that mm/MM are the same.
It solves the issue

This is a good resource for all the different format identifiers.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.