web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieving the data by passing date and time attribute using Web Api

(0) ShareShare
ReportReport
Posted on by 307

Hi Experts,

We have fields called start time and End Time(Date and Time).when ever user entering time sheet record with start time and end time ,we need to restrict if time overlapping with existing records.I have tried with filter query(Web API) for matching records to find duplication,but i am not able to get records for date and time field.

Please help me on this to resolve the issue.

Thanks in advance.


Best Regards,
Seenivasan

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Sreenivasan,

    You could try the URL below.

    Hope this helps.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Please use ge and le as date field will always have time part and there is no way we can get date part only of a date and use it in odata filter. Another way to do it is to make your Start time field as Date only

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Mohd Saad Akhtar,

    Thanks for your response.I am getting same results.

    Its giving 0 records.

    Best Regards,

    Seenivasan

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Use like this:

    sandbox4.crm8.dynamics.com/.../new_entity2s$select=new_starttime,createdon&$filter=new_starttime eq 2017-05-17T00:00:00.000Z

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Nithya Gopinath,,

    I have tried your query.

    query:

    sandbox4.crm8.dynamics.com/.../new_entity2s$select=new_starttime,createdon&$filter=new_starttime eq (2017-05-17)

    Result:

    {
      "@odata.context":"sandbox4.crm8.dynamics.com/.../v8.2$metadata#new_entity2s(new_starttime,createdon)","value":[
        
      ]
    }

    Its giving 0 records.But i have a record in CRM for this date "2017-05-17".


    Best Records,
    Seenivasan



  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Sreenivasan,

    You could just pass the required date only to the query string as shown below.

    https://<orgname>.api.crm4.dynamics.com/api/data/v8.2/accounts?$filter=createdon%20eq%20(2017-05-15)

    In order to get the date part from date time field, use the Javascript code below.

    var dateTimeFieldValue= Xrm.Page.getAttribute('datetimefieldname').getValue();
    var year = dateTimeFieldValue.getFullYear();
    var month = dateTimeFieldValue.getMonth();
    var day = dateTimeFieldValue.getDate();
    var dateOnly = new Date(year,month,day);

    Hope this helps.

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Gopalan Bhuvanesh,

    can you please tell me,query for filter based on Date(not time included).

    For example:

    I have a field called new_startTime which is Date and Time format.I want to pass the value of  "new_startTime"(only date) to query string for new_starttime and retrieve the matching records.

    Thanks and Records,

    Seenivasan

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Mohd Saad Akhtar,

    Thank you for your response.

    It was worked after removing "datetime" string from the format.

    Format should be like:

    new_starttime eq (" + startTimeFormat + ")";

    Thanks and Regards,

    Seenivasan

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Nithya Gopinath,

    Thanks for your response.

    It was worked after removing "datetime" string from the format.

    Format should be like:

    new_starttime eq (" + startTimeFormat + ")";

    Thanks and Regards,

    Seenivasan

  • Seenivasan M Profile Picture
    307 on at
    RE: Retrieving the data by passing date and time attribute using Web Api

    Hi Gopalan Bhuvanesh,

    Thank you so much.

    I truly appreciate your time.

    Thanks and Regards,

    Seenivasan

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans