Skip to content

Date Parsing C#

January 30, 2012
Here are some Date Parsing tips using C#
DateTime.ParseExact(txtdate.text, "MM/dd/yyyy hh:mm", null); 
You can also use TryParse like so which avoids exceptions being thrown if the date format is incorrect or something: -

A thing that I found frustrating is that if you use the DateTime? as the type used commonly for NHibernate doesn't work so you have to change it to DateTime.
I am still pondering as to why DateTime? is used????? (Yeh more question marks!)


From → Uncategorized

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: