Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

How to Filter Date column in web api query?

Posted on by

I need syntax for retrieving issuestarttime is >= 2 years from today.  The pseudo code equivalent is issuestarttime >= DAY(TODAY()) - 760

How to do in web api query (pulling from Dynamics CRM)?

As first step I am trying to merely retrieve data greator than/equal to a given date, but am getting error:

I HAVE TRIED
https://OK.api.crm.dynamics.com/api/data/v8.1/mc_alerts?$select=_mc_symptomtypealertid_value,mc_resolutiontime,mc_alertnumber,statuscode,statecode,mc_fixphases,mc_alertid,%20mc_symptomdurationhours,%20mc_name,%20mc_symptomdurationtotalminutes,%20mc_customersaffected,%20mc_eventdurationdays,%20mc_resolutiontime,%20mc_eventdurationtotalminutes,%20mc_eventdurationminutes,%20mc_businessimpact,%20mc_alertnumber,%20mc_eventdurationhours,%20mc_symptomdurationdays,%20new_totalcustomersimpacted,%20mc_symptomdurationminutes,%20mc_issuestarttime,%20mc_severityid,%20mc_subtypeid,%20mc_symptomtypealertid,mc_fixphases,_mc_severityid_value,mc_reportedstarttime,_mc_subtypeid_value&$filter=statecode%20eq%200%20and%20statuscode%20eq%20100000000%20or%20statuscode%20eq%20100000000%20or%20statuscode%20eq%201%20and%20mc_issuestarttime ge ('2015-06-01 00:00:00')

Error

DataSource.Error: Microsoft.Mashup.Engine1.Library.Resources.HttpResource: Request failed:
OData Version: 3 and 4, Error: The remote server returned an error: (400) Bad Request. (A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThanOrEqual'.)
OData Version: 4, Error: The remote server returned an error: (400) Bad Request. (A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThanOrEqual'.)
Details:
    DataSourceKind=OData
    DataSourcePath=https://missioncontrol.api.crm.dynamics.com/api/data/v8.1/mc_alerts

Thanks in advance.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Filter Date column in web api query?

    use date without time and pass in below format and recommend to always use UTC.

    Below worked for me:

    accounts?$filter=modifiedon ge 2018-04-28

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Filter Date column in web api query?

    Same problem, did you ever figure this out? It works great when the field is just a DateTime field. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans