Showing posts with label How to check datetime. Show all posts
Showing posts with label How to check datetime. Show all posts

Monday, February 25, 2008

How to check datetime, numeric !

How to check datetime

If you use vb.net, this is not a problem for you but I think some people using c# have a trouble in there.Now, I will explain how to check datetime.I will explain two ways.
first way is so easy.you should add this method and use it.

public bool isDate(string date) {
try{
DateTime dt=DateTime.parse(date);
return true;
}
catch(Exception ex){
return false;
}
}

But this is not a good way.How is second.Second way is so beauty.

public bool checkDate(string date){
DateTime d;
return DateTime.TryParse(date,d);
}







Google Ad