Reputation: 4795
I need a date (not a dateTime) to be passed to a web service,
I tried like that :
[WebMethod]
public void myMethod([XmlElementAttribute(DataType = "date")] DateTime someDate)
{
// ...
}
But it still produce :
<tns:myMethod xsi:type="tns:myMethod">
<someDate xsi:type="xsd:dateTime">dateTime</someDate>
</tns:myMethod>
Any idea ?
Upvotes: 0
Views: 1121
Reputation: 73594
In .NET, even the System.DateTime.Date is a DateTime data type (documentaiton). There is no such thing as a "Date" datatype without the time in .NET.
The date portion of a DateTime will evaluate to midnight of that date, d
DateTime DateOnly = DateTime.Now.Date;
Console.Out.WriteLine(DateOnly.ToString("yyyy-MM-dd hh:mm:ss");
will write out
2012-09-10 00:00:00
Within your code you can access just the date using the code above, but regardless, it's going to be a DateTime value.
Of course, SOAP Encoding does have a Date datatype, but .NET has nothing to match it to, other than the DateTime Data Type.
Unless you write your own data type, which would probably be a colossal waste of time.
Upvotes: 1