TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Terry Showers
NA
3
4.7k
How do I convert an XML DateTime in a web method
Aug 26 2010 2:18 PM
I am passing a string into a webservice that contains a date formatted as "2010-08-26T00:00:00". this format is required by the infoPath form that passes this through XML.
When I try to convert the date into a usable date in the web method I get an error "System.FormatException: String was not recognized as a valid DateTime" when I run the application (InfoPath form).
The partial code for the web method looks like:
public string CheckDuplicates(string StartDate)
{
DateTime datStartDate = DateTime.Parse(StartDate);
(the error occurs on the first line of the method doing the parse)
The code works correctly if I hard code the line like:
DateTime datStartDate = DateTime.Parse("2010-08-26T00:00:00");
The application is an InfoPath form that calls this web service and passes the string, I can view the string and verify that it matches the format I indicated previously but the web method gets confused.
Is there something wrong in my code or the way I am using Parse?
Reply
Answers (
2
)
Fiscal Printer
I need help bad in fixing this problem