web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Inogic Profile Picture
    703 on at

    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!

     

     

     

     

  • Community Member Profile Picture
    on at

    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.

  • Verified answer
    Leonardo Mizikami Profile Picture
    152 on at

    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());

  • Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans