.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

C# equiv of isdate?

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :.NET Framework
 

Hi,

How do i check if a string contains a valid date?

Ex, i have a string ="jan 6 15:15", I want to set the year to 2006, but only if it's not already a valid date as is the case.

so, the resulting string should be "jan 6 2006 15:15". but if the string already has a valid date, ex "jan 7 2005", I don't want to touch it.

I try to use the datetime.parse inside a try/catch, but i couldn't get it to fail.  It keeps setting the date to now().

Has anyone done this before?




View Complete Post


More Related Resource Links

FAQ: What is the equivalent function in C# for the function IsDate in VB?

  

What is the equivalent function in C# for the function IsDate in VB?


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend