Jump to content
Sign in to follow this  
it9888

Dates in Web services

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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...