I try to pass 2 datetime parameters into my webget but I can't figure out how to get it to work properly I will show you my code below and the error i get maybe somebody nows how this works .
[WebGet]
public IQueryable<TestTable> GetCallersByDate(string beginDate, string eindDate)
{
testCDREntities context = this.CurrentDataSource;
DateTime startDt = DateTime.Parse(beginDate);
DateTime endDt = DateTime.Parse(eindDate);
var selectedOrders = from table in context.TestTables
where table.Created >= startDt && table.Created <= endDt
select table;
return selectedOrders;
}
The url :
http://localhost:50088/WebService.svc/GetCallersByDate?beginDate=2016/03/23T20:22:30:14&eindDate=2016/03/2T20:13:11:03
I hope somebody can help me ?
Given the data below, you should use DateTime.ParseExact instead of the usual DateTime.Parse
We can see that the format of the date string is yyyy/MM/ddTHH:mm:ss and AFAIK that this format is not native to .NET
beginDate=2016/03/23T20:22:30:14 eindDate=2016/03/2T20:13:11:03
string dateFormat = "yyyy/MM/ddTHH:mm:ss";
DateTime startDt = DateTime.ParseExact(beginDate, dateFormat, CultureInfo.InvariantCulture);
DateTime endDt = DateTime.Parse(eindDate, dateFormat, CultureInfo.InvariantCulture);