Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM Web API: how to query data that current Date between date range

(1) ShareShare
ReportReport
Posted on by

How I use javascript to call CRM Web API, I would like to query some data that current date between date range. But I cannot to use DateTime.Now() to get current date with javascript, because the date would be local time, it is not safe.

So is there any way can get the Current Date with CRM Web API?

Or is there any way can query data between date range?  I tried view, but I cannot find properly condition.

*This post is locked for comments

  • RE: CRM Web API: how to query data that current Date between date range

    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

  • RE: CRM Web API: how to query data that current Date between date range

    Thanks for replying. But I don't think we can use 'var now = new Date();' to get current date, it is local time of user's PC, it would change if user change his PC time. It is not safe.

  • Verified answer
    Leonardo Mizikami Profile Picture
    Leonardo Mizikami 150 on at
    RE: CRM Web API: how to query data that current Date between date range

    You can use this to get the UTC time

    var now = new Date();

    var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),  now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());

  • RE: CRM Web API: how to query data that current Date between date range

    Thanks for replying.  But the date get in javascript is local time, I don't want it. I just want to get the current Date of CRM.

  • Inogic Profile Picture
    Inogic 438 on at
    RE: CRM Web API: how to query data that current Date between date range

    In  javascript to get the current Date use this function  â€“ new Date()

    For Example-

            var  currentDate =new Date();

     

    For  query data between date range –(Retrieve Accounts which are created between Date 11-01-2017 to 30-03-2017)

    https://[organizationUrl]/api/data/v8.2/accounts?$filter=createdon le 2017-03-30 and createdon ge 2017-01-11 &$select=name 

     

     

    If this answered your question, please make sure to Mark this as an Answer.

    Thanks!

     

     

     

     

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans