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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to specify datetime-type filter

(0) ShareShare
ReportReport
Posted on by
Hello everyone.

I would like to use the following filter with Dynamics CRM select.
---
modifiedon gt 2018-01-02 03:04:05.000+0900
---



However, the following error occurs.
---
Syntax error at position 27 in 'modifiedon gt 2018-01-02 03:04:05.000+0900'.
---

Please tell me if there is a specification method.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    If you are using WEB API use the below to format you date and then pass it in filter

    var formatCreatedOn = clientReviewPage.getODataUTCDateFilter(youdatefield)

    filter:      createdon lt " + formatCreatedOn 

    function getODataUTCDateFilter (date) {
    	var monthString;
        var rawMonth = (date.getUTCMonth() + 1).toString();
        if (rawMonth.length == 1) {
            monthString = "0" + rawMonth;
        }
        else { monthString = rawMonth; }
     
        var dateString;
        var rawDate = date.getUTCDate().toString();
        if (rawDate.length == 1) {
            dateString = "0" + rawDate;
        }
        else { dateString = rawDate; }
     
        var hourString = date.getUTCHours().toString();
        if (hourString.length == 1)
            hourString = "0" + hourString;
     
        var minuteString = date.getUTCMinutes().toString();
        if (minuteString.length == 1)
            minuteString = "0" + minuteString;
     
        var secondString = date.getUTCSeconds().toString();
        if (secondString.length == 1)
            secondString = "0" + secondString;
     
        var DateFilter = "(";
        DateFilter += date.getUTCFullYear() + "-";
        DateFilter += monthString + "-";
        DateFilter += dateString;
        DateFilter += "T" + hourString + ":";
        DateFilter += minuteString + ":";
        DateFilter += secondString + "Z)";
        return DateFilter;
    }
  • Verified answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    You can also convert your string to ISO String which should give you the correct results

    var myDate = "2018-01-02 03:04:05.000+0900"; // Not sure where you are getting it from

    var dateString = myDate.toISOString();

    then use:

    var filter = "modifiedon gt " + dateString;

    Try this out...

  • Community Member Profile Picture
    on at

    Thank you very much. I will try it.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans