Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime.Parse...

Status
Not open for further replies.

Kris11

Programmer
Jan 31, 2003
278
US
I recently found that if I pass in a date string like the this

Code:
DateTime.Parse("01-01/2002");

DateTime.Parse, parses it correctly and returns back 01/01/2002. Is this a documented behavior? Have you seen any documentation which discuss a behavior like this.

Just curious...

-Kris
 
.Parse() is pretty flexible, and it does a pretty good job most of the time, but I'm surprised it would accept something like that!

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
I imagine MS is using Regex's that allow you to put any crap in the middle of a date tag as long as its not numeric and it will still work.

Try parsing 02!-..01/1995 and see if it goes. Now that would be amazing.
 
Too bad SQL Server isn't as forgiving, I tried dumping the format in the RSS spit out by google news into a SQL DateTime and it fails (i.e. "Sun, 16 Oct 2005 04:10:43 GMT") had to DateTime.Parse().ToString() it, so no biggie. thank goodness for static methods ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top