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)

Apply Date filter in Odata Query

(0) ShareShare
ReportReport
Posted on by 382

Hi Experts,

here is my Query

var oDataQuery = "f1_workorderSet$select=f1_workorderId,f1_WorkOrderType,f1_ServiceAccount

&$expand=f1_account_f1_workorder_ServiceAccount&$filter=f1_WorkOrderType/Id eq (guid'" + workordertypeId + "') and f1_ServiceAccount/Id eq (guid'" + acountId + "') and $filter=createdOn gt " + datefilter + "";

where my datefilter is "datetime'2014-12-14T14:54:25Z'"  (Question : do i need to pass the variable value along with Z at the end ?)

something is wrong ..unable to get result suggest solution .

i get the above format after passing datetime to below function

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 = "datetime'";

DateFilter += date.getUTCFullYear() + "-";

DateFilter += monthString + "-";

DateFilter += dateString;

DateFilter += "T" + hourString + ":";

DateFilter += minuteString + ":";

DateFilter += secondString + "'";

return DateFilter;

}

 

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    datetime'2014-12-14T14:54:25Z' is correct, but the field name is CreatedOn, not createdOn

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