DateTime.ParseExact method a life saver :-)

This is a pretty sweet method when it comes to checking the validity of formatted dates. Our users are so much used to typing in MMDDYY in the mainframe that they wanted this option in our application too. We could not just make them type in MMDDYY without checking for the validity of it. That is when DataTime.ParseExact helped us so much. All you do is something like this:

DateTime objDate = DateTime.ParseExact("051109", "MMddyy", System.Threading.Thread.CurrentThread.CurrentCulture);

Hope this helps.

Happy Programming!!!



0 Responses to “DateTime.ParseExact method a life saver :-)”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: