Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate dates passed as parameters
Message
From
31/03/2004 14:53:42
 
 
To
31/03/2004 14:39:46
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00891236
Message ID:
00891277
Views:
23
Very good question.

The dates are taken from a free fpw2.6 data table. The dates are in character format ie: "dd/mm/yy".
The data in the free tables is over 15 years old and I am stuck with dates being formatted in this way. I pass the dates to my method and then convert to date via:
public string OrthoAge(string tcRefDate)
{
  DateTime dRefDate = DateTime.Parse(tcRefDate)
   .......
   /// lots of date math
   .......
   return dRefDate.ToString()
}
Once I have the old fpw character dates converted I can do what I have to (ie: lots of date math). I just need a way to make certain that the date converts from character to DateTime without throwing an error. I could wrap the conversion-to-date in a try/ catch construct but I was wondering if there was a better way.

Regards,
Neil

>
>>Can someone please offer a way to validate that a date passed as a parameter to a method is in fact a valid date prior to it being passed to the method.
>
>Silly question, but why would you need to? A DateTime variable will be a valid date.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform