Hi @Shola Ogunde .
This behavior is expected.
According to the remark in DateTime.ParseExact Method.
The DateTime.ParseExact(String, String, IFormatProvider) method parses the string representation of a date, which must be in the format defined by the
format
parameter. It also requires that the <Date> and <Time> elements of the string representation of a date and time appear in the order specified byformat
, and thats
have no white space other than that permitted byformat
. Ifformat
defines a date with no time element and the parse operation succeeds, the resulting DateTime value has a time of midnight (00:00:00). Ifformat
defines a time with no date element and the parse operation succeeds, the resulting DateTime value has a date ofDateTime.Now.Date
.
Because the format used for parsing is a string type parameter, not restricted to an enumeration type.
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.