473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to pass a DateTime value to a WebMethod

Hi all..

I have a WebMethod with a parameter defined as DateTime. When I call that
webservice, I get this error:
System.FormatException: The string '07/24/2005' is not a valid AllXsd value.

It seems that dates aren't recognized. I tried using several date formats,
for example, dd/mm/yyyy, mm/dd/yyyy, yyyy/mm/dd, and so on, without success.

Any help woud be greatly appreciated,

Thanks
Jaime
Nov 23 '05 #1
2 23714
You can use a String (ToString) to connect them BUT if the two system
regions are different, there maybe an error.

So, I have my own way.

Public Function TimeCodeMaker(ByVal Time As DateTime) As String
Return Format(Time.Year Mod 100, "00") + Format(Time.Month, "00") +
Format(Time.Day, "00") + Format(Time.Hour, "00") + Format(Time.Minute, "00")
+ Format(Time.Second, "00") + Format(Time.Millisecond \ 100, "0")
End Function

Public Function TimeCodeDecoder(ByVal TimeString As String) As DateTime
Return New DateTime(Val(Mid(TimeString, 1, 2)), Val(Mid(TimeString,
3, 2)), Val(Mid(TimeString, 5, 2)), Val(Mid(TimeString, 7, 2)),
Val(Mid(TimeString, 9, 2)), Val(Mid(TimeString, 11, 2)), Val(Mid(TimeString,
13, 1)) * 100)
End Function

"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi all..

I have a WebMethod with a parameter defined as DateTime. When I call that
webservice, I get this error:
System.FormatException: The string '07/24/2005' is not a valid AllXsd
value.

It seems that dates aren't recognized. I tried using several date formats,
for example, dd/mm/yyyy, mm/dd/yyyy, yyyy/mm/dd, and so on, without
success.

Any help woud be greatly appreciated,

Thanks
Jaime

Nov 23 '05 #2
Thanks Allen for answerring...

I have finally searched the XSD specification and I have found that the date
has to be passed using the format: CCYY-MM-DD, so I set as a requirement of
my webservice the date to be passed using that format.

Jaime
"Allen St.Clair" wrote:
You can use a String (ToString) to connect them BUT if the two system
regions are different, there maybe an error.

So, I have my own way.

Public Function TimeCodeMaker(ByVal Time As DateTime) As String
Return Format(Time.Year Mod 100, "00") + Format(Time.Month, "00") +
Format(Time.Day, "00") + Format(Time.Hour, "00") + Format(Time.Minute, "00")
+ Format(Time.Second, "00") + Format(Time.Millisecond \ 100, "0")
End Function

Public Function TimeCodeDecoder(ByVal TimeString As String) As DateTime
Return New DateTime(Val(Mid(TimeString, 1, 2)), Val(Mid(TimeString,
3, 2)), Val(Mid(TimeString, 5, 2)), Val(Mid(TimeString, 7, 2)),
Val(Mid(TimeString, 9, 2)), Val(Mid(TimeString, 11, 2)), Val(Mid(TimeString,
13, 1)) * 100)
End Function

"Jaime Stuardo" <Ja**********@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi all..

I have a WebMethod with a parameter defined as DateTime. When I call that
webservice, I get this error:
System.FormatException: The string '07/24/2005' is not a valid AllXsd
value.

It seems that dates aren't recognized. I tried using several date formats,
for example, dd/mm/yyyy, mm/dd/yyyy, yyyy/mm/dd, and so on, without
success.

Any help woud be greatly appreciated,

Thanks
Jaime


Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: news.microsoft.com | last post by:
Hello, I have DateTime property. How can I set this value to null?
4
by: Frank Meng | last post by:
Hi. I want to save a DateTime value with format like "2004-02-11T12:11:17.0000000-05:00" using XmlTextWriter. I think I should write codes something like: StreamWriter sw=new...
1
by: ABC | last post by:
How to convert a date string to datetime value with custom date format? e.g. Date String Date Format Result (DateTime value) "05/07/2004" "MM/dd/yyyy" May 7, 2004 "01062005" ...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
4
by: Arpan | last post by:
A SQL Server 2005 DB table has 4 columns namely "ID" (IDENTITY int column), "FirstName" (varchar(50)), "LastName" (varchar(50)) & "DOB" (datetime). Now when I am trying to add a new row using the...
5
by: cpnet | last post by:
I'm able to pass string parameters with no problems to a LocalReport being displayed by the ASP.NET ReportViewer control. However, my report also has a DateTime parameter. ...
15
by: mayurtandel | last post by:
i have problem whith store datetime value to database table the my system date formate is dd/mm/yyyy the date is store in mm/dd/yyyy formate what is the problem my code is as follow Public...
4
by: kinaxx | last post by:
Hello, now I'm learning progamming language in university. but i have some question. in textbook. says there are four passing Mechanism 1) pass by value (inother words : call by value) 2)...
10
by: Newbie | last post by:
howdy... i am trying to execute a statement where i insert a record with datetime values into a sql database. Dim sqlcmd As New SqlCommand sqlcmd.CommandText = "update tbl_event set...
2
by: raam | last post by:
create proc getproviders as begin select ProviderType,ProviderTypeId,ProviderName,City,State,Country, ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.