如何在odata url中传递日期参数

时间:2015-01-20 06:35:35

标签: java web-services rest odata

对于此输入,我只想查询日期参数,下面是我的网址

http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')/ Trips?$ filter = StartsAt eq DateTime'2014-01-01T00:00:00'

{
    "@odata.context": "http://services.odata.org/V4/(S(sdkgbnxmswihlweriznxbilh))/TripPinServiceRW/$metadata#People('russellwhyte')/Trips",
    "value": [
        {
            "TripId": 0,
            "ShareId": "9d9b2fa0-efbf-490e-a5e3-bac8f7d47354",
            "Description": "Trip from San Francisco to New York City. Nice trip with two friends. 
            "Name": "Trip in US",
            "Budget": 3000,
            "StartsAt": "2014-01-01T00:00:00Z",
            "EndsAt": "2014-01-04T00:00:00Z",
            "Tags": [
                "Trip in New York",
                "business",
                "sightseeing"
            ]
        },
}

但是当我使用日期参数尝试查询时,我收到错误。 请告诉我这个查询中的错误

1 个答案:

答案 0 :(得分:0)

在最新的.NetCore中,这种适用于DateTime的格式非常完美。

http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')/Trips?$filter=StartsAt eq 2014-01-01T00:00:00Z