Jump to content

Dates in Web services


it9888

Recommended Posts

I have a webservice with several functions. One function requires a parameter of type date. When testing my webservice I realised that this date should be given in no other format than YYYY-MM-DD. I would like to make a conversion function that will take as parameter the date and convert it to the above mentioned format. My problem is that I don't really know how the user will type the date. Could be: YYYY/MM/DD or MM/DD/YYYY or DD-MM-YYYY etc. Actually, a user while testing, gave the following date: YYYYMMDD. Is there any conversion function that I can use?

Link to comment
Share on other sites

I've seen it mentioned a number of times in this forum that the only reliable way to capture date input from users is to set up three fields: one for month, one for day, and one for year. Whether this fields are text fields or drop down menus would be up to you. Another alternative would be to find yourself a calendar control that you could put on your page that would allow a user to select a date from the calendar and have that calendar return the date to your script in a standardized format.

Link to comment
Share on other sites

Thanks for your reply jesh. I don't think that web services work in this way though. Correct me If I'm wrong but I think I cannot control the way dates are captured since I'm not the one developing the consumer. The only thing I could do is having three fileds for year, month, days like you suggested.

Link to comment
Share on other sites

Thanks for your reply jesh. I don't think that web services work in this way though. Correct me If I'm wrong but I think I cannot control the way dates are captured since I'm not the one developing the consumer. The only thing I could do is having three fileds for year, month, days like you suggested.
Yeah, that's right since you aren't able to control the consumers. I would guess that you would minimize errors if the structure of the date in the request looked something along the lines of:
<date>  <month>3</month>  <day>14</day>  <year>2007</year></date>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...