When I need to insert date into the database I need to check 2 things:
Currently I'm checking this using a long function filled with if's
and else's
.
Is there any method in C#
that can check a date if it's valid or not before I insert it?
DateTime temp;
if (DateTime.TryParse(yourString, out temp))
{
//valid, use temp to insert into DB.
}
else
{
//not valid.
}