After experiencing a very hard time browsing the internet for answers on how to retrieve items from a SharePoint list using the Modified or Created field as a filter for getting items created or modified on the current day , I then came up with the following implementation in javascript/jquery:
If you are using REST API the datetime literal is used as, e.g. datetime'2013-03-12T12:01:38Z' (This is ISO format) or datetime'2013-03-12′. Therefore, I needed the date in the format yyyy-mm-dd.
Here is the Code for filtering the list:
- var d = new Date();
- var date = convertToDate(d);
-
- var querypath = "http://farmname.com/site/_vti_bin/listdata.svc/listName?$filter=Modified gt datetime'"+date+"'";
- $.ajax({
- url:querypath,
- type: "GET",
- dataType: "json",
- headers: {
- Accept: "application/json;odata=verbose"
- }
- });
- function convertToDate(date)
- {
- var mnth = date.getMonth() + 1;
- var day = "";
-
-
- if(date.getDate()<10)
- {
- day = "0"+date.getDate().toString();
- }
- else day = date.getDate().toString();
-
- return date.getFullYear() + "-" + mnth + "-" + day;
- }
I hope this will help many who face this kind of challenge!